Javascript Match email , phone number and special characters from a String(textarea)


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function validatEmail(txt_msg)
  2. {
  3. var pattern = /[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}/g;
  4. return(pattern.test(txt_msg));
  5. }
  6.  
  7. function validatMobile(txt_msg)
  8. {
  9. var testPattern = /[0-9]{10,11}/;
  10. return( testPattern.test(txt_msg));
  11. }
  12.  
  13. function validateSpecialCharacters(txt_msg)
  14. {
  15. var testPattern = /[-[\]{}()*+?.,\\^$|#\s]/;
  16. return( testPattern.test(txt_msg));
  17. }

URL: http://simonwillison.net/2006/Jan/20/escape/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.