Sunday, April 25, 2010

URL Validation Using Javascript

if(!(/^http:\/\/www\.[0-9]|[a-z]+\.(com)|(org)|(edu)|(net)|(co.in)|(co.uk)|(info)|(me)|(mobi)|(us)|(biz)|(ca)|(tv)|(de) $/.test(document.form.url.value))){
    alert("Please enter Valid Web Address");
    document.form.url.focus();
    return false;
}
In the above validation 'form' is the Form name & 'url' is the text box name to validate.

No comments: