Following is the requirement of field value should be - else it should generate an error
Format to be only 9 characters with 2 letters, followed by 6 numbers, followed by one letter
e.g. 'AB332211C'
Any else value should generate an error message using JavaScript. Can anyone help me in creating regex expression for this.
EDITS : Till yet I am done with this : Help to improve the same
--------------------------------------------------------------------------
var myAssumption = /^\d{2}[a-zA-z] \d{6}[0-9]\d{1}[a-zA-z]$/;
--------------------------------------------------------------------------
Following links might help in answering : http://www.java2s.com/Code/JavaScript/Form-Control/Mustbeatleast3charactersandnotmorethan8.htm
Examples :
// Common regexs
var regexEmail = /^([\w]+)(.[\w]+)*@([\w]+)(.[\w]{2,3}){1,2}$/;
var regexUrl = /^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}([\w]+)(.[\w]+){1,2}$/;
var regexDate = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;
var regexTime = /^([1-9]|1[0-2]):[0-5]\d$/;
var regexIP = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
var regexInteger = /(^-?\d\d*$)/; **
strong text**