|
|
|
ขอcode javascript ที่ checkในการกรอก url ขอcode javascript ที่ checkในการกรอก url นะครับ |
|
|
|
|
|
|
|
<script language="JavaScript">
function CheckValidUrl(strUrl)
{
var RegexUrl = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
return RegexUrl.test(strUrl);
}
alert(CheckValidUrl("http://www.geekpedia.com"));
</script>
|
|
|
|
|
Date :
18 ส.ค. 2551 18:47:14 |
By :
Softman |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (JavaScript)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<form name="frmMain" action="" method="post" OnSubmit="return chkSubmit()">
<script language="javascript">
function CheckValidUrl(strUrl){
var RegExp = /^(([\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})*)?$/;
return RegExp.test(strUrl);
}
function chkSubmit()
{
if(CheckValidUrl(document.frmMain.txtUrl.value)==false)
{
alert('Please enter new url');
return false;
}
}
</script>
Input URL <input type="text" name="txtUrl" value="">
<input type="submit" name="butSubmit" value="Check">
</form>
</body>
</html>
|
|
|
|
|
Date :
2011-05-09 17:51:20 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|