regular expression validation example

var textval=$('data').val();
var regex =/^[A-Za-z0-9 ,]+$/;
if( !regex.test(textval) ) {
    alert('tex should not be empty or invalid character \nsupported character are A to Z, a to z, 0 to 9 , space and comma ( , ) ');
    return false;
}
Author: bm on February 13, 2014
Category: jquery