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

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -