html - Comparing data of two textboxes is not working using jquery -


i want compare data of 2 text boxes using jquery compare password , confirm password while making email account. still have following stuff.

css

.test {     display:none; } 

html

<input type="text" name="t1" /> <input type="text" name="t2" /> <label class="test" name="lblerror">error</label> 

jquery

$("#t2").click(function () {     if ($("#t1").val() === $("#t2").val()) {} else {         $("#lblerror").removeclass("test");     } }); 

demo

please me, how can compare these 2 strings while leaving second text box named t2.

thanks in advance.

try this

you using name id in jquery, wrong. convert name id. work.

<input type="text" id="t1" /> <input type="text" id="t2" /> <label class="test" id="lblerror">error</label> 

js

$(function(){     $("#t2").change(function () {                  if ($("#t1").val() === $("#t2").val()) {                     $("#lblerror").addclass("test");                         }                 else {                     $("#lblerror").removeclass("test");                 }             });     }); 

demo


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -