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

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -