There is a JavaScript function that is normally called through a form tag, using onsubmit.
In the code it looks like this:
<form method="post" name="form1" id="form1" onsubmit="return validate(this)">
If I were going to call the validate function through some other method, what variable would I pass it? I mean, the ‘this’ in the onsubmit call, what would I put there instead? Would it be the id of the form, so "form1"?
thisrefers to the element that the tag creates, that is, the form element. So you would call it with:For more information on events, check out this introduction. The onsubmit attribute you’re using is an inline event handler.