Leo67
10-09-2003, 02:36 PM
Hi,
Charles had helped me earlier today with form validation for Users who could enter either a postal code or zip code into the same input field. I have looked at the code on the site he had recommended to me devedge.netscape.com/library/manuals/2000/javascript/1.3/guide/regexp.html (http://devedge.netscape.com/library/manuals/2000/javascript/1.3/guide/regexp.html) and I am trying to add a - character after the third character in the Postal Code but of course not adding the - after the third character of the Zip Code.
The code that is currently in place is:
String.prototype.isPostalCode = function () {return /^([A-Za-z]\d){3}$/.test(this) || /^\d{5}(-\d{4})?$/.test(this)}
The code I think I should add into the current code has been highlighted in red .... and I keep getting a syntax error for that line.
String.prototype.isPostalCode = function () {return /^([A-Za-z]\d){3}$/([-]){4}$/.test(this) || /^\d{5}(-\d{4})?$/.test(this)}
Charles had helped me earlier today with form validation for Users who could enter either a postal code or zip code into the same input field. I have looked at the code on the site he had recommended to me devedge.netscape.com/library/manuals/2000/javascript/1.3/guide/regexp.html (http://devedge.netscape.com/library/manuals/2000/javascript/1.3/guide/regexp.html) and I am trying to add a - character after the third character in the Postal Code but of course not adding the - after the third character of the Zip Code.
The code that is currently in place is:
String.prototype.isPostalCode = function () {return /^([A-Za-z]\d){3}$/.test(this) || /^\d{5}(-\d{4})?$/.test(this)}
The code I think I should add into the current code has been highlighted in red .... and I keep getting a syntax error for that line.
String.prototype.isPostalCode = function () {return /^([A-Za-z]\d){3}$/([-]){4}$/.test(this) || /^\d{5}(-\d{4})?$/.test(this)}