PRodgers4284
02-19-2008, 03:18 PM
I need some validation to check the format of a website address eg (www.websiteaddress.com) but im having difficulty finding code to do this, can anyone help me or provide some advice? Would really appreciate it.
|
||||
Website address form validationPRodgers4284 02-19-2008, 03:18 PM I need some validation to check the format of a website address eg (www.websiteaddress.com) but im having difficulty finding code to do this, can anyone help me or provide some advice? Would really appreciate it. oesxyl 02-19-2008, 03:24 PM I need some validation to check the format of a website address eg (www.websiteaddress.com) but im having difficulty finding code to do this, can anyone help me or provide some advice? Would really appreciate it. what kind of validation? some basic things you can do, using: http://www.php.net/manual/en/ref.url.php if you use them take care of php version. best regards _Aerospace_Eng_ 02-19-2008, 03:52 PM I use this on a few of the sites I've made function validateURL($str) { if(!preg_match("/^[a-zA-Z]+[:\/\/]+[A-Za-z0-9\-_]+\\.+[A-Za-z0-9\.\/%&=\?\-_]+$/i",$str)) { return false; } } // Usage: if(validateURL('http://codingforums.com')) { echo 'The url is valid'; } else { echo 'The url is not valid'; } PRodgers4284 02-19-2008, 04:01 PM I use this on a few of the sites I've made function validateURL($str) { if(!preg_match("/^[a-zA-Z]+[:\/\/]+[A-Za-z0-9\-_]+\\.+[A-Za-z0-9\.\/%&=\?\-_]+$/i",$str)) { return false; } } // Usage: if(validateURL('http://codingforums.com')) { echo 'The url is valid'; } else { echo 'The url is not valid'; } Thanks for the reply, il give that a go, thanks ago |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum