javascript - Proper way of invoking a function to validate data before submitting a form -
in understanting, have 2 options this:
a) on html form, assign function on "onsubmit" attribute, , use function return false if goes wrong. submitting form, submit-type button can used.
b) have non-submit button, triggers javascript function on-click; then, function, "form.submit();" call , force submition.
is there practical difference between these 2 methods / prefered method of doing this? pro - cons, etc? now, see them being matter of taste,but if there's functional difference might come handy knowing it!
thanks lot
you may use "onchange" event listener not allowing enter invalid data in form
Comments
Post a Comment