We are using the following to do an email validation in ASP.NET:
\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
How can this be modified to ignore leading and trailing spaces?
The actual trimming we handle in code on postback but the validator is triggering as being invalid if the user has an extra space often due to copying and paste.
You can place \s*
before and after your pattern and it should work properly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With