Skip to content

Instantly share code, notes, and snippets.

@23maverick23
Created February 20, 2014 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 23maverick23/9125771 to your computer and use it in GitHub Desktop.
Save 23maverick23/9125771 to your computer and use it in GitHub Desktop.
NSOA: Perform a simple URL validation on a custom field
/**
* 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