HI,
I have a input requirement of string pattern from front end.
the string can be aa-bbb-cccc the first word would be minimum 2 then second word would be between (3 to 5 character) and the last word can be (4 to 7 character)
each word is separated by a hyphen.
so that i have written one regular expression but it is not working can any one help me.
i am not able to find the problem.
- var CustomeExp=/^([a-zA-z]{2})-([a-zA-Z]{3,5})-([a-zA-Z]{4,7})$/;
- here is my code which...
- Enter your text :
- "text" onkeypress="return validateKeypress(CustomeExp);">
JS
- var CustomeExp=/^([a-zA-z]{2})-([a-zA-Z]{3,5})-([a-zA-Z]{4,7})$/;
- function validateKeypress(validChars) {
- //alert(validChars);
- var keyChar = String.fromCharCode(event.which || event.keyCode);
- //alert(keyChar);
- return validChars.test(keyChar) ? keyChar : false;
- }
Thanks

Rajeesh MenothPosted Jan 3, 2020, 12:41 AM
ammar zaidiPosted Jan 3, 2020, 12:41 AM