Title
Disable 'submit' type input with onclick event
Body

Hi,

  'submit' type input for a form has 'disabled' property; default value is false for this to allow submission of the form fields. When true, it becomes disabled but does not submit the form inputs to server.

I had faced such a scenario with 'onclick' event, but I got both 'disabled' property and form fields submission together with a following trick.

Rails:--

<%=submit_tag 'Submit', :onclick=>'this.disabled=true;this.form.submit();' %>

HTML:--

<input type='submit' value='Submit' onclick='this.disabled=true;this.form.submit();'/>

Cheers

Alok Anand

Rails Detective

Associated Tags
button, disable, disabled, form submission on submit disabled, form submit, input, onclick, submit, submit button, submit_tag, type
Created By
alokanand
Created At
2011-12-16 10:31:12 UTC
Last Updated At
2011-12-16 10:31:12 UTC
Add Comment