<script><li> $(function(){<li><li> var ok1=false;<li> var ok2=false ;<li> var ok3=false;<li> var ok4=false;<li> // Verify username<li> $('input[name="username"]').focus(function(){<li> $(this).next(). text('The username should be between 3-20 characters').removeClass('state1').addClass('state2');<li> }).blur(function(){<li> if($(this).val( ).length >= 3 && $(this).val().length <=12 && $(this).val()!=''){<li> $(this).next().text(' Input successful').removeClass('state1').addClass('state4');<li> ok1=true;<li> }else{<li> $(this).next().text('The user name should be between 3-20 characters between').removeClass('state1').addClass('state3');<li> }<li> <li> });<li><li> //Verify password<li> $('input[name="password"]').focus(function( ){<li> $(this).next().text('The password should be between 6-20 characters').removeClass('state1').addClass('state2');<li> }).blur(function() {<li> if($(this).val().length >= 6 && $(this).val().length <=20 && $(this).val()!=''){<li> $ (this).next().text('Input successful').removeClass('state1').addClass('state4');<li> ok2=true;<li> }else{<li> $(this).next().text ('The password should be between 6-20 characters').removeClass('state1').addClass('state3');<li> }<li> <li> });<li><li> //Verify and confirm the password<li> $('input[name= "repass"]').focus(function(){<li> $(this).next().text('The confirmation password entered must be consistent with the password above, and the rules must be the same').removeClass('state1') .addClass('state2');<li> }).blur(function(){<li> if($(this).val().length >= 6 && $(this).val().length <=20 && $(this).val()!='' && $(this).val() == $('input[name="password"]').val()){<li> $(this).next ().text('Input successful').removeClass('state1').addClass('state4');<li> ok3=true;<li> }else{<li> $(this).next().text('Confirmation of input The password must be consistent with the password above, and the rules must be the same').removeClass('state1').addClass('state3');<li> }<li> <li> });<li><li> //Verify email<li> $('input[name= "email"]').focus(function(){<li> $(this).next().text('Please enter the correct EMAIL format').removeClass('state1').addClass('state2');<li> }).blur(function(){<li> if($(this).val().search(/w+([-+.]w+)*@w+([-.]w+)*.w+([-. ]w+)*/)==-1){<li> $(this).next().text('Please enter the correct EMAIL format').removeClass('state1').addClass('state3');<li> } else{ <li> $(this).next().text('Input successful').removeClass('state1').addClass('state4');<li> ok4=true;<li> }<li> <li> });<li><li> // Submit button, all verifications must be passed to submit<li><li> $('.submit').click(function(){<li> if(ok1 && ok2 && ok3 && ok4){<li> $('form').submit();<li> }else{<li> return false;<li> }<li> });<li> <li> });<li> </script>
Copy Code
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn