Salve a tutti,
volevo capire alcune cose riguardo a "this" in javascript, in particolare su questo esempio tratto da w3schools:
Codice PHP:
<html> <head>
<script type="text/javascript">
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
{
alert(alerttxt);return false;
} else { return true; } } }
function validate_form(thisform) {
with (thisform) {
if (validate_required(email,"Email must be filled out!")==false) {
email.focus();return false;} } }
</script>
</head>
<body> <form action="submit.htm" onsubmit="return validate_form(this)" method="post">
Email: <input type="text" name="email" size="30"> <input type="submit" value="Submit">
</form>
</body>
</html>
la funzione validate_form(thisform) cosa prende come parametro, document.forms[]?
la chiamata validate_required(email, "Email must be filled"), come fa a passargli "email"? Non dovrebbe passarlo tramite document.getElementByName("email") ??
Inoltre:
if (value==null||value==""), come può essere usata se value non esiste?
Grazie.