[Solved] How to do validation for text box in JavaScript [closed]


Use the following code in your “keyup blur” event handler

$(function() {
    $('input.alpha[$id=tb1]'.bind('keyup blur', function() {
        if (this.value.search(/^[a-zA-Z]*$/) === -1) {
          alert("Only valid characters present");
        }
     }); 
});

Use + instead of * if you don’t want to allow empty matches for regex.

solved How to do validation for text box in JavaScript [closed]