Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery compare two fields values
    primarykey
    data
    text
    <p>hi i have a sign up form , it has six input fields</p> <h1>html code</h1> <pre><code>&lt;div id="signup"&gt; &lt;form id="suform" method="POST" action="signup/newUser"&gt; &lt;p&gt; &lt;label&gt;Frist Name&lt;/label&gt; &lt;input type="text" name="fName"/&gt; &lt;span class="errorMessage"&gt;&lt;/span&gt; &lt;/p&gt; &lt;p&gt; &lt;label&gt;Last Name&lt;/label&gt; &lt;input type="text" name="lName"/&gt; &lt;span class="errorMessage"&gt;&lt;/span&gt; &lt;/p&gt; &lt;p&gt; &lt;label&gt;Email&lt;/label&gt; &lt;input type="text" name="Email"/&gt; &lt;span class="errorMessage"&gt;&lt;/span&gt; &lt;/p&gt; &lt;p&gt; &lt;label&gt;Mobile Number&lt;/label&gt; &lt;input type="text" name="MNumber"/&gt; &lt;span class="errorMessage"&gt;&lt;/span&gt; &lt;/p&gt; &lt;p&gt; &lt;label&gt;Password&lt;/label&gt; &lt;input type="password" name="Password"/&gt; &lt;span class="errorMessage"&gt;&lt;/span&gt; &lt;/p&gt; &lt;p&gt; &lt;label&gt;Re Password&lt;/label&gt; &lt;input type="password" name="RePassword"/&gt; &lt;span class="errorMessage"&gt;&lt;/span&gt; &lt;/p&gt; &lt;p&gt; &lt;input type="submit" class="button" value="sign up"/&gt; &lt;/p&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p>when the user clicked sign up button , first i ensure that no input fields is empty , if i found any input fields in empty then i print an error message left to that input field ,</p> <h1>jquery code</h1> <pre><code>$(document).ready(function(){ $('#suform').on('submit', function(e){ e.preventDefault(); var errorCount = 0; $('span.errorMessage').text(''); // reset all error mesaage $('input').each(function(){ var $this = $(this); if($this.val() === ''){ var error = 'Please fill ' + $this.prev('label').text(); // take the input field from label $this.next('span').text(error); errorCount = errorCount + 1; } }); if(errorCount === 0){ $(this)[0].submit(); // submit form if no error } }); }); </code></pre> <p>i want the user to input his password twice to ensure that he saves it</p> <p> my question is how to check the two passwords input fields if they are equal or not , and if not i want to print a message error to the left of that two input fields</p> <p><a href="http://jsfiddle.net/Wiliam_Kinaan/8wV58/4/" rel="nofollow">code</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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