Jump to content

Rule Help


mcmuney

Recommended Posts

I'm using the following to validate that a valid URL has been entered, BUT when I enter a valid url that starts with a number, it doesn't accept it as valid. I'd appreciate someone modifying the code to accept urls that start with a number (this is not my area):

 

<script type="text/javascript">
function validate_url(o,e){
var patu = /^(((ht|f)tp(s?))\:\/\/)?(www.|[a-zA-Z].)[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,4}){1,2}(\:[0-9]+)*(\/($|[a-zA-Z0-9\.\,\;\?\'\\\+&%\$#\=~_\-]+))*$/i;
var patd = /^[a-zA-Z][a-zA-Z0-9]+(\.[a-zA-Z0-9]+)+$/i;
R=$("#frm1url").val();
if(R && R.length>0 && R.match(patu)!=null){
	return true;
}else if(R && R.length>0 && R.match(patd)!=null){
	return true;
}else{
	alert("Invalid url entered");
	return false;
}
}
</script>

 

Thanks in advance.

Link to comment
Share on other sites

Try this:

 

<script type="text/javascript">
function validate_url(o,e){
var patu = /^(((ht|f)tp(s?))\:\/\/)?(www.|[a-zA-Z0-9].)[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,4}){1,2}(\:[0-9]+)*(\/($|[a-zA-Z0-9\.\,\;\?\'\\\+&%\$#\=~_\-]+))*$/i;
var patd = /^[a-zA-Z0-9][a-zA-Z0-9]+(\.[a-zA-Z0-9]+)+$/i;
R=$("#frm1url").val();
if(R && R.length>0 && R.match(patu)!=null){
	return true;
}else if(R && R.length>0 && R.match(patd)!=null){
	return true;
}else{
	alert("Invalid url entered");
	return false;
}
}
</script>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.