I have two regular expressions for one user input field that should accept a websites contact page url or an email address. How can I write this in Jquery or Javascript? Here are my two regular expressions.
regex for URL "((www\.|(http|https|ftp|news|file)+\:\/\/)[_.a-z0-9-]+\.[a-z0-9\/_:@=.+?,##%&~-]*[^.|\'|\# |!|\(|?|,| |>|<|;|\)])",
regex for email "^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$",
error messageelse "You must enter a valid email or you must enter a valid url, which starts with http://. The www prefix is optional.")
Demo – http://jsfiddle.net/A77fD/
Example –