Created
February 20, 2014 23:42
-
-
Save 23maverick23/9125771 to your computer and use it in GitHub Desktop.
NSOA: Perform a simple URL validation on a custom field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simple url validation for custom field. | |
* | |
* Version Date Author Remarks | |
* 1.00 20 Feb 2014 Ryan Morrissey | |
* | |
*/ | |
function validateURL() { | |
var url = NSOA.form.getValue('custom_30'), | |
re = /^(ftp|http|https):\/\/[^ "]+$/, | |
test = re.test(url); | |
if (!test) { | |
var errMsg = '' + | |
'Invalid URL. Ensure you use ftp/http/https ' + | |
' and remove any spaces or double quotes.' + | |
''; | |
NSOA.form.error('custom_30', errMsg); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment