HI,
By using "pattern" attribute inside an input tag you can do validation without writing any code. You will need to write a regex inside a pattern attribute to support this. This came with HTML5
YOu can check these examples for reference
Working with HTML5 pattern attribute
On the other side, as Brenden said, I would also avoid that.
Regards
Chetan