javascript - jQuery focus not allowing moving out -


i using jquery .focus() make textbox receive focus if input incorrect. when textbox receives focus, can't lose it. want user able select other textboxes too. how can this?

function checkpassword() {   var password = $("#password").val();   var password2 = $("#password-reenter").val(); if(password != null){   if (password === password2) {     //alert("passwords match");      $("#password-reenter").css('border','1px solid gray');     $("#password-warning").hide();     $("#password, #password-reenter").next('span').removeclass().addclass('ui-icon ui-icon-check');   } else {      $("#password-reenter").attr('title','the passwords not match. please reenter password.').css('border','3px solid red').focus();     } } }; 

no problem found...

you have other code out there triggering focus.

check snippet:

$("#password-reenter")    .attr('title','the passwords not match. please reenter thepassword.')    .css('border','3px solid red').focus();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>  <input type="text" id="password-reenter" />  <input type="text" />

edit:

after looking @ code (given in comment) found this:

<input type="password" name="password-reenter" id="password-reenter" onfocusout="checkpassword()" style="font-family: latine; border: 3px solid red;" required="" title="the passwords not match. please reenter password."> 

as can see onfocusout="checkpassword()" cause problem because calls checkpassword() focus again if passwords don't match.


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -