Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to prevent submit button from submitting until DOM is loaded?

I'm doing form validation using jquery validate plugin. It works great, however if DOM is not fully loaded and you click submit button then the document ignores validation and goes to a page specified in form "action" attribute. Is it possible to prevent submit button from submitting until DOM is loaded?

like image 938
Dmitry Avatar asked Jul 31 '11 14:07

Dmitry


1 Answers

If you generate your submit button like so:

<input type="submit" id="submit" value="submit" disabled="disabled"/>

Then you can put this in your $(document).ready( right after the validation plugin has been initialised:

$("#submit").prop("disabled", false);

Demo: http://jsfiddle.net/nZVrs/

like image 190
karim79 Avatar answered Sep 19 '22 06:09

karim79