javascript - Jquery validation of string and date -


i want validate 3 input field http://jsfiddle.net/hskat/20/

  1. only add date

is there regular expression validating this.. dont want use plugins

$('.validate-string').change(function (e) {     var valid_str = $(this).val();     ........  }); 

here 1 method validate string , number.. date have define format want, kindly check below code number , string

 $(document).ready(function () {         $('.validate-string').change(function (e) {             var valid_str = $(this).val();            var regex = /^[a-za-z ]*$/;             if (regex.test(valid_str)) {                 alert("valid");             } else {                 alert("invalid");             }          });          $('.validate-number').change(function (e) {             var valid_num = $(this).val();              if(!valid_num.match(/^[0-9,\+-]+$/)){              alert("only numbers allow");                  return false;              }          });        $('.validate-date').change(function (e) {         var valid_date = $(this).val(); //yyyy-mm-dd        var filter = /^\d{4}-\d{1,2}-\d{1,2}$/;  if(filter.test(valid_date))   alert("date");  else   alert("not date");     }); });     }); 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -