Start with one example:
For validate Name Field: Alphabets, numbers and space(' ') no special characters min 3 and max 20 characters.
var ck_name = /^[A-Za-z0-9 ]{3,20}$/;
{3,10} Check for the string length in between give boundary.
For validate Name Field: Alphabets, numbers and space(' ') no special characters min 3 and max 20 characters.
var ck_name = /^[A-Za-z0-9 ]{3,20}$/;
if (!ck_name.test(name))
{
alert('Enter valid Name.');
return false;
}
alert('Enter valid Name.');
return false;
}
Note: The above code for front end using JavaScript. If you are using PHP use key word preg_match instead of test.
Some important conditions:
[abc] | Find any character between the brackets |
[^abc] | Find any character not between the brackets |
[0-9] | Find any digit from 0 to 9 |
[A-Z] | Find any character from uppercase A to uppercase Z |
[a-z] | Find any character from lowercase a to lowercase z |
Important Links:
No comments:
Post a Comment