I'm trying to match the following format:
T123ABC
When people insert they could do it with spaces or dashes. I am trying to use this format for jquery validator but for some reason it is not working:
$.validator.addMethod('numberplateTZ', function (value) {
var reg = value.replace(" ","");
reg = reg.replace("-","");
return /[a-z]{1}[0-9]{3}[a-z]{3}$/.test(reg);
}, 'Numberplate format: T XXX ABC...');
replace()with string, replaces a single occurrence, to replace all occurrences usereplace(/\s+/g, ''). Missing anchor^in regex. Useiflag for case-insensitive match.