Search This Blog

Tuesday, 28 August 2012

Email and URL validation in Javascript using Regular Expression

JavaScrip URL & Email Validation
Enter Valid URL :
Enter Valid Email :

4 comments:

  1. but from where i get the code???

    ReplyDelete
    Replies
    1. bellow is url validation expresssion

      /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/

      Delete
  2. function is_valid_url(url)
    {
    return url.match(/^(ht|f)tps?:\/\/[a-z0-9-\.]+\.[a-z]{2,4}\/?([^\s<>\#%"\,\{\}\\|\\\^\[\]`]+)?$/);
    }

    ReplyDelete
  3. thanx Anonymous this worked for me
    ;)

    ReplyDelete