Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- Trying to combine two scripts and open in a new window


rocknbil - 4:27 pm on Mar 16, 2012 (gmt 0)


I know the user can copy and paste the vin # into the form field and click go and it will perform as it should.


Right, because the text field starts and ends with the pattern. When used that way, it's a good idea to trim off trailing and leading spaces (i.e., "help the user because they may not know" or may be copying and pasting from Word, which often adds a trailing space.)

The only thing I'd add to your regex is possibly make it case insensitive in the event someone enters it in lower case.

var reg = '/[A-Z0-9]{17}/i';

Optional, 0-9 and \d are identical. :-) The dash defines a a range, so it's appropriate for that - that is, everything between and including 2 to 8 would be [2-8]. Really it's the difference between saying "any digit" and "0 1 2 3 4 5 6 7 8 9" or "zero through nine".

var reg = '/[A-Z\d]{17}/i';


Thread source:: http://www.webmasterworld.com/javascript/4428738.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com