asp.net - Use of Key Up event in Jquery -


i want validate textbox using jquery.

if number of letters' length increased 6, hide <span> tag

html:

<input type="password" id="txtpass" value="" onkeyup="keyup();"/> 

javascript:

function keyup () {             var x =$("#txtpass").val();     if (x.length < 6) {         $("span").show()     }     else          (x.length >= 6)     {         $("span").hide();     } } 

advise please

use keyup function of jquery , length , show/hide (or use toggle):

$('#txtpass').keyup(function(){     if($(this).val().length < 6){         $("span").show();     }     else if($(this).val().length >= 6){        $("span").hide();     } }); 

Comments