javascript - jQuery focus on Alert box with clicking on button -


i have form, after submitting form when button clicked using jquery this.

function validate(){    if($('#firstname').val() =="")            alert("please enter first name");    else if($('#lastname').val() == "")     alert("please enter last name");    else if( $('#association').val() == "")     alert("choose association");    else if($('#association_no').val() == "")     alert("please enter association number");    else     $('#register').submit();   }     $(function(){          $(".enter_submit").keyup(function(event) {         if(event.keycode === 13)          validate();        })    }) 

the alert box displaying fine issue when press enter after alert box displayed, gives alert box instead of getting rid of alert(works fine when click ok mouse). in ff, gives #prevent more alerts page. believe still focusing on form after alert displayed.

specify return false after alert box displayed. might not show other alert box @ same time.

function validate() {             if ($('#firstname').val() == "") {                 alert("please enter first name");                 return false;             }             else if ($('#lastname').val() == "") {                 alert("please enter last name");                 return false;             }             else if ($('#association').val() == "") {                 alert("choose association");                 return false;             }             else if ($('#association_no').val() == "") {                 alert("please enter association number");                 return false;             }             else {                 $('#register').submit();                 return true;             }         }           $(function () {             $(".enter_submit").keyup(function (event) {                 if (event.keycode === 13)                     return validate();             });         }); 

hope help

thanks prashant


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -