Note that there are some explanatory texts on larger screens.

plurals
  1. PORe-enable submit button if form validation fails
    text
    copied!<p>I have a form which onsubmit() validates the form contents and hides the submit button and shows an image while its processing.</p> <pre><code>$(document).ready(function() { $('input[type="submit"]').click(function() { $(this).css('display', 'none'); $('&lt;img&gt;').attr('src', '../images/ajax-loader.gif').insertAfter($(this)); }); }); </code></pre> <p>JS:</p> <pre><code>function validateForm() { var x=document.forms["trial"]["username"].value; var splitted = x.match("^(.+)@abcd\.com$"); if (splitted != null) { return true; } return false; } </code></pre> <p>HTML:</p> <pre><code>echo "&lt;FORM name=\"trial\" action=\"index2.php\" method=\"POST\" onsubmit=\"return validateForm();\"&gt;"; echo "Access-Type: "; echo "&lt;select name=\"accesstype\" id=\"accesstype\"&gt;"; echo "&lt;option value=\"select\"&gt;-SELECT-&lt;/option&gt;"; echo "&lt;option value=\"adsl\"&gt;ADSL&lt;/option&gt;"; echo "&lt;option value=\"cable\"&gt;CABLE&lt;/option&gt;"; echo "&lt;/select&gt;&lt;br&gt;&lt;br&gt;"; echo "&lt;span id=\"username\" class=\"details\"&gt;Username (e.g john.smith@abcd.com) : &lt;input id=\"username\" type=\"text\" name=\"username\" maxlength=\"40\"&gt;&lt;/span&gt;&lt;br&gt;&lt;br&gt;"; echo "&lt;input type=\"submit\" name=\"submit\" value=\"submit\"&gt;"; echo "&lt;/FORM&gt;"; </code></pre> <p>It works fine so far if all the details provided by the user meet the requirements. However, if the form validation fails, I want the submit button to re-appear for the user to be able to make the necessary changes and resubmit the form.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload