View Single Post
Old 12-07-2007, 01:38 PM   #7 (permalink)
Matt83
The Contributor
Upcoming Programmer 
 
Matt83's Avatar
 
Join Date: Oct 2007
Location: Argentina
Posts: 72
Thanks: 18
Matt83 is on a distinguished road
Default

I been playing a bit with prototype and thought of giving this a try, im sure it can be improved but anyways here it is, i hope it helps:

HTML Code:
	<script src="prototype.js" type="text/javascript"></script>
	<script type="text/javascript">
	function validateURL (szURL,szTarget,szForm) 
	{
		var bValid = /^(http|https|ftp):\/\/([\w]*)\.([\w]*)\.(com|net|org|biz|info|mobi|us|cc|bz|tv|ws|name|co|me)(\.[a-z]{1,3})?$/.test(szURL);
		if (bValid == false) {
			$(szTarget).innerHTML = "Please enter a valid URL.";
		} else {
			$(szTarget).innerHTML = "Valid URL.";
			// $(szForm).submit();
 		}
	};
	</script>
<h1>Validate URL</h1>
<form id="myForm" action="" method="post">
	<p><label>Url:</label><br/>
	<input type="text" name="url" value="" id="url" size="40"/></p>
	<div id="info"></div>
	<p><input type="button" value="Send URL &rarr;"  onclick="validateURL($('url').value,'info','myForm')"/></p>
</form>
__________________
http://www.mattvarone.com
Matt83 is offline  
Reply With Quote