Say I have the following HTML:
<form>
...some form fields...
<input type="submit" id="submitButton" value="Submit" />
</form>
And I have a javascript method validate
that checks the form fields for various invalid scenarios, returning true
if all is well or false
if there's something wrong.
Is there any real difference in jQuery between doing this:
$("form").submit(function() {
return validate();
});
...or doing this:
$("#submitButton").click(function(){
return validate();
});
And are there any advantages/disadvantages between the two?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…