javascript - How to exclude validation for blank space -
To validate a textbox, I have the following regular expressions in my code: Validate a certain format of expression text However, I need a case where the user leaves the text box blank, it is also valid. This form does not match when submitting the form with an empty text box. I want to remove this case. How do i do this
^ [A -Za-J 0-9 -] + (\\. [A-Za-z0-9-] +) * (\ [A-Za -Z] {2,}) $
You can hardly have your full match conditional. ...
^ ([A-Za-z0-9 -] + (\\. [A-Za-z0-9 -] +) * (\ \ [A-Za - {2}} {0,1} $
The entire expression (except ^) and $ (...) {0,1} in the beginning and end anchors, the bracketed expression directs the Regex engine to match 0 or 1 time. Match results 0 times in an empty string pass validation.
Comments
Post a Comment