I am using Jquery Validation.
Currently, I have a username, what i want to validate for this username is:
- Not blank
- Availability
No whitespaces, I add this method:
$.validator.addMethod("nowhitespace", function(value, element) { return this.optional(element) || /^\S+$/i.test(value); }, " No white space please");
Alphanumeric
$.validator.addMethod("alphanumeric", function(value, element) { return this.optional(element) || /^[a-zA-Z0-9]+$/i.test(value); }, " Alphanumeric. Only numbers and alphabet allowed");
First characters must be alphabet, cannot be numeric.
I am stuck at the last validation. How to write a regular expression to validate first character MUST be alphabet?
BTW:
The no whitespace seems having problem. I tried my script, 1 whitespace its allowed, but 2 whitespaces not allowed, why?