Sanjeev Chauhan Sanjeev Chauhan - 2 months ago 13
jQuery Question

jquery Form validation for Housenumber

How to validate the below Housenumber using jquery Form validation?

1
1b
12
12b
123
123b
1234
1234b


the letter should be always last position , but not required. Please help me to create regular expression.

Answer Source

The following RegExp will do:

/^\d+[a-zA-Z]*$/
  • ^ Must start with
  • \d+ Any number (\d), at least once (+)
  • [a-zA-Z]* Some letters [a-zA-Z] (optional: *)
  • $ Must end here