javascript - Alert box error -


i have allow alphabets text box. have validated through javascript on text box using "on blur". alert javascript remains open though try close.

find demo link , javascript below.

note: type non-alphabet in text box 1 , press tab or click on somewhere else following link.

http://demo.acclary.com/test.aspx

the javascript used is, below:

function checkalphabets(textbox) { var pattern = /^[a-za-z\s]+$/; if (!pattern.test(textbox.value)) {     modal({         type: 'warning',         title: 'warning',         text: 'only alphabets allowed!',         center: false,     });     settimeout(function () { textbox.focus(); }, 1);     exit;     return false; } return true; }   $('.modal-btn').click(function() {      $('#modal-window').hide();  }); 

you need add following line of code in modal function:

callback: function(){ $("#mytextbox").focus();} 

so after change,

 modal({     type: 'warning',     title: 'warning',     text: 'only alphabets allowed!',     center: false,     callback: function(){ $("#mytextbox").focus();}      }); 

that's all. have created fiddle using modal plugin using in page. http://jsfiddle.net/7kpsv1p4/1/


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -