WordPress/wp-includes/js/tinymce/utils/validate.js
matt 751a663f3c Missing directory
git-svn-id: http://svn.automattic.com/wordpress/trunk@2954 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2005-10-18 16:40:06 +00:00

51 lines
1.7 KiB
JavaScript

/**
* $RCSfile: validate.js,v $
* $Revision: 1.2 $
* $Date: 2005/08/13 12:20:37 $
*
* Various form validation methods.
*
* @author Moxiecode
* @copyright Copyright © 2005, Moxiecode Systems AB, All rights reserved.
*/
function testRegExp(form_name, element_name, re) {
return new RegExp(re).test(document.forms[form_name].elements[element_name].value);
}
function validateString(form_name, element_name) {
return (document.forms[form_name].elements[element_name].value.length > 0);
}
function validateSelection(form_name, element_name) {
return (document.forms[form_name].elements[element_name].selectedIndex > 0);
}
function validateCheckBox(form_name, element_name) {
return document.forms[form_name].elements[element_name].checked;
}
function validateCleanString(form_name, element_name) {
return testRegExp(form_name, element_name, '^[A-Za-z0-9_]+$');
}
function validateEmail(form_name, element_name) {
return testRegExp(form_name, element_name, '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$');
}
function validateAbsUrl(form_name, element_name) {
return testRegExp(form_name, element_name, '^(news|telnet|nttp|file|http|ftp|https)://[-A-Za-z0-9\\.]+$');
}
function validateNumber(form_name, element_name, allow_blank) {
return (!allow_blank && value == '') ? false : testRegExp(form_name, element_name, '^-?[0-9]*\\.?[0-9]*$');
}
function validateSize(form_name, element_name,) {
return testRegExp(form_name, element_name, '^[0-9]+(px|%)?$');
}
function validateID(form_name, element_name,) {
return testRegExp(form_name, element_name, '^[A-Za-z_]([A-Za-z0-9_])*$');
}