URL Validate : Form Validation : Form Control : JavaScript DHTML examples (example source code) Organized by topic

JavaScript DHTML
C++
PHP
JavaScript DHTML Home »  Form Control   » [  Form Validation  ]   
 



URL Validate

Please note that some example is only working under IE or Firefox.

/*
JavaScript: A Beginner's Guide, Second Edition
By John Pollock

Publisher: McGraw-Hill, 

Published December 2003, 550 pages, 
ISBN 0072227907
*/

<HTML>

<HEAD>

<SCRIPT language="JavaScript">
<!--

function check_it()
{
 var theurl=document.f1.t1.value;
 var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/
 if (tomatch.test(theurl))
 {
 window.alert("URL OK.");
 return true;
 }
 else
 {
 window.alert("URL invalid. Try again.");
 return false
}
}
//-->
</SCRIPT>

</HEAD>

<BODY>

<FORM name="f1" action="#" onSubmit="return check_it();">
Enter URL:<BR>
<INPUT type="text" name="t1">
<BR>
<INPUT type="submit" value="Submit">
</BODY>

</HTML>

           
       
Related examples in the same category
1.  Form Validator: time, date email, phone number, age etc
2.  Form Validate: is blank, is digit and is integer
3.  Log in form validation
4.  Log in email validation
5.  Comprehensive form validation
6.  Illegal sub string validation
7.  Email form validation
8.  Form Validator
9.  Form valiation for empty data, file name
10.  Email Address Validate
11.  Time Validate








Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.