| Author |
Regular Expression Help
|
Alvaro Sanchez
Greenhorn
Joined: Aug 26, 2008
Posts: 2
|
|
I'm trying to create a regular expression that does the following: ABC1234567890 It needs to verify that the first 3 or 4 (fourth letter is optional) digits are letters (no special characters, no numbers) and the following digits are only numbers on a range from 7 to maximum 10 digits. I'm close but i can't quite get what I want yet. Any help appreciated, thanks!!!
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56185
|
|
|
What have you come up with so far?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Alvaro Sanchez
Greenhorn
Joined: Aug 26, 2008
Posts: 2
|
|
I forgot to mention all this is inside a 'keyup' event on mootools, so it checks as the user is typing the info into the form. I got what I wanted here is the solution, it may help other user: if(lic_pre2.length < 3){ var regex = '^([A-Z]*)$'; var regexp = new RegExp(regex); var licRegExp = regexp.test(lic_pre2); if (licRegExp == false){ //Print your error here } }else{ var regex2 = '^([A-Z]{2,3}[0-9]{0,10})$'; var regexp3 = new RegExp(regex2); var licRegExp2 = regexp3.test(lic_pre2); if (licRegExp2 == false){ //Print error here } [ August 26, 2008: Message edited by: Alvaro Sanchez ]
|
 |
 |
|
|
subject: Regular Expression Help
|
|
|