/** * Constructor * * @access public * @param string $field Field to validate * @param string $error Error to print * @param string $comparefield Field to compare the password entry */ function JSPasswordMatchValidator($field, $error, $comparefield) { parent::__construct($field, $error); $this->_code = "if (form." . $this->_field . ".value == form." . $comparefield . ".value) {\n"; $this->_code .= " alert ('" . $this->_error . "');\n"; $this->_code .= " form." . $this->_field . ".focus ();\n"; $this->_code .= " return false;\n"; $this->_code .= "}\n\n"; }
/** * Constructor * * @access public * @param string $field Field to validate * @param string $error Error to print */ function JSEmailValidator($field, $error) { parent::__construct($field, $error); $this->_code = "if (!isValidEmail(form." . $this->_field . ".value)) {\n"; $this->_code .= " alert ('" . $this->_error . "');\n"; $this->_code .= " form." . $this->_field . ".focus ();\n"; $this->_code .= " return false;\n"; $this->_code .= "}\n\n"; }
/** * Constructor * * @access public * @param string $field Field to validate * @param string $error Error to print * @param int $max Max length * @param int $min Min length (Default 0) */ function JSLengthValidator($field, $error, $max, $min = 0) { parent::__construct($field, $error); $this->_code = "if (!isValidLength(form." . $this->_field . ".value, {$min}, {$max})) {\n"; $this->_code .= " alert ('" . $this->_error . "');\n"; $this->_code .= " form." . $this->_field . ".focus ();\n"; $this->_code .= " return false;\n"; $this->_code .= "}\n\n"; }
/** * Constructor * * @access public * @param string $field Field to validate * @param string $error Error to print */ function JSRequiredValidator($field, $error) { parent::__construct($field, $error); $this->_code = "if (form." . $this->_field . ".value == '') {\n"; $this->_code .= " alert ('" . $this->_error . "');\n"; $this->_code .= " form." . $this->_field . ".focus ();\n"; $this->_code .= " return false;\n"; $this->_code .= "}\n\n"; }
/** * Constructor * * @access public * @param string $field Field to validate * @param string $error Error to print */ function JSSocialSecurityValidator($field, $error) { parent::__construct($field, $error); $regexp = "/^(?=((0[1-9]0)|([1-7][1-7]\\d)|(00[1-9])|(0[1-9][1-9]))-(?=(([1-9]0)|(0[1-9])|([1-9][1-9]))-(?=((\\d{3}[1-9])\$|([1-9]\\d{3})\$|(\\d[1-9]\\d{2})\$|(\\d{2}[1-9]\\d)\$))))/"; $this->_code = "if (!form." . $this->_field . ".value.match ({$regexp})) {\n"; $this->_code .= " alert ('" . $this->_error . "');\n"; $this->_code .= " form." . $this->_field . ".focus ();\n"; $this->_code .= " return false;\n"; $this->_code .= "}\n\n"; }
/** * Constructor * * @access public * @param string $field Field to validate * @param string $error Error to print */ function JSUnixNetDeviceValidator($field, $error) { parent::__construct($field, $error); $regexp = "/^(eth[0-9]\$)|(^eth[0-9]:[1-9]\$)/"; $this->_code = "if (!form." . $this->_field . ".value.match ({$regexp})) {\n"; $this->_code .= " alert ('" . $this->_error . "');\n"; $this->_code .= " form." . $this->_field . ".focus ();\n"; $this->_code .= " return false;\n"; $this->_code .= "}\n\n"; }
/** * Constructor * * @access public * @param string $field Field to validate * @param string $error Error to print */ function JSMacValidator($field, $error) { parent::__construct($field, $error); $regexp = "/^([0-9a-fA-F][0-9a-fA-F][-.:]?){5}([0-9a-fA-F][0-9a-fA-F])\$/"; $this->_code = "if (!form." . $this->_field . ".value.match ({$regexp})) {\n"; $this->_code .= " alert ('" . $this->_error . "');\n"; $this->_code .= " form." . $this->_field . ".focus ();\n"; $this->_code .= " return false;\n"; $this->_code .= "}\n\n"; }
/** * Constructor * * @access public * @param string $field Field to validate * @param string $error Error to print */ function JSMoneyValidator($field, $error) { parent::__construct($field, $error); $regexp = "/^\$?([1-9]{1}[0-9]{0,2}(\\,[0-9]{3})*(\\.[0-9]{0,2})?|[1-9]{1}[0-9]{0,}(\\.[0-9]{0,2})?|0(\\.[0-9]{0,2})?|(\\.[0-9]{1,2})?)\$/"; $this->_code = "if (!form." . $this->_field . ".value.match ({$regexp})) {\n"; $this->_code .= " alert ('" . $this->_error . "');\n"; $this->_code .= " form." . $this->_field . ".focus ();\n"; $this->_code .= " return false;\n"; $this->_code .= "}\n\n"; }
/** * Constructor * * @access public * @param string $field Field to validate * @param string $error Error to print */ function JSURLValidator($field, $error) { parent::__construct($field, $error); $regexp = "/^(http\\:\\/\\/)?[a-z0-9\\-]+\\.([a-z0-9\\-]+\\.)?[a-z]+\$/"; $this->_code = "if (!form." . $this->_field . ".value.match ({$regexp})) {\n"; $this->_code .= " alert ('" . $this->_error . "');\n"; $this->_code .= " form." . $this->_field . ".focus ();\n"; $this->_code .= " return false;\n"; $this->_code .= "}\n\n"; }
/** * Constructor * * @access public * @param string $field Field to validate * @param string $error Error to print */ function JSFloatValidator($field, $error) { parent::__construct($field, $error); $regexp = "/^\\d*\\.?\\d*\$/"; $this->_code = "if (!form." . $this->_field . ".value.match ({$regexp})) {\n"; $this->_code .= " alert ('" . $this->_error . "');\n"; $this->_code .= " form." . $this->_field . ".focus ();\n"; $this->_code .= " return false;\n"; $this->_code .= "}\n\n"; }
/** * Constructor * * @access public * @param string $field Field to validate * @param string $error Error to print */ function JSSMTPValidator($field, $error) { parent::__construct($field, $error); $regexp = "/^(smtp)\\.([\\w\\-]+)\\.[\\w\\-]{2,3}\$/"; $this->_code = "if (!form." . $this->_field . ".value.match ({$regexp})) {\n"; $this->_code .= " alert ('" . $this->_error . "');\n"; $this->_code .= " form." . $this->_field . ".focus ();\n"; $this->_code .= " return false;\n"; $this->_code .= "}\n\n"; }
/** * Constructor * * @access public * @param string $field Field to validate * @param string $error Error to print */ function JSStrongPasswordValidator($field, $error) { parent::__construct($field, $error); $regexp = "/^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\\s).{4,8}\$/"; $this->_code = "if (!form." . $this->_field . ".value.match ({$regexp})) {\n"; $this->_code .= " alert ('" . $this->_error . "');\n"; $this->_code .= " form." . $this->_field . ".focus ();\n"; $this->_code .= " return false;\n"; $this->_code .= "}\n\n"; }
/** * Constructor * * @access public * @param string $field Field to validate * @param string $error Error to print */ function JSISBNValidator($field, $error) { parent::__construct($field, $error); $regexp = "/^ISBN (?=.{13}\$)\\d{1,5}([- ])\\d{1,7}\\d{1,6}(\\d|X)\$/"; $this->_code = "if (!form." . $this->_field . ".value.match ({$regexp})) {\n"; $this->_code .= " alert ('" . $this->_error . "');\n"; $this->_code .= " form." . $this->_field . ".focus ();\n"; $this->_code .= " return false;\n"; $this->_code .= "}\n\n"; }
/** * Constructor * * @access public * @param string $field Field to validate * @param string $error Error to print */ function JSXMLValidator($field, $error) { parent::__construct($field, $error); $regexp = '/<(\\w+)(\\s(\\w*=".*?")?)*((/>)|((/*?)>.*?</\\1>))/'; $this->_code = "if (!form." . $this->_field . ".value.match ({$regexp})) {\n"; $this->_code .= " alert ('" . $this->_error . "');\n"; $this->_code .= " form." . $this->_field . ".focus ();\n"; $this->_code .= " return false;\n"; $this->_code .= "}\n\n"; }
/** * Constructor * * @access public * @param string $field Field to validate * @param string $error Error to print */ function JSIPValidator($field, $error) { parent::__construct($field, $error); $regexp = "/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\$/"; $this->_code = "if (!form." . $this->_field . ".value.match ({$regexp})) {\n"; $this->_code .= " alert ('" . $this->_error . "');\n"; $this->_code .= " form." . $this->_field . ".focus ();\n"; $this->_code .= " return false;\n"; $this->_code .= "}\n\n"; }
/** * Constructor * * @access public * @param string $field Field to validate * @param string $error Error to print */ function JSPositiveNumericValidator($field, $error) { parent::__construct($field, $error); $regexp = "/^[0-9]*[1-9]+\$|^[1-9]+[0-9]*\$/"; $this->_code = "if (!form." . $this->_field . ".value.match ({$regexp})) {\n"; $this->_code .= " alert ('" . $this->_error . "');\n"; $this->_code .= " form." . $this->_field . ".focus ();\n"; $this->_code .= " return false;\n"; $this->_code .= "}\n\n"; }
/** * Constructor * * @access public * @param string $field Field to validate * @param string $error Error to print */ function JSSQLInjectionValidator($field, $error) { parent::__construct($field, $error); $regexp = "/(script)|(<)|(>)|(%3c)|(%3e)|(SELECT) |(UPDATE) |(INSERT) |(DELETE)|(GRANT) |(REVOKE)|(UNION)|(<)|(>)/"; $this->_code = "if (!form." . $this->_field . ".value.match ({$regexp})) {\n"; $this->_code .= " alert ('" . $this->_error . "');\n"; $this->_code .= " form." . $this->_field . ".focus ();\n"; $this->_code .= " return false;\n"; $this->_code .= "}\n\n"; }
/** * Constructor * * @access public * @param string $field Field to validate * @param string $error Error to print * @param string $cardtype CardType field to use as reference */ function JSCreditCardValidator($field, $error, $cardtype) { parent::_construct($field, $error, $cardtype); if (empty($cardtype)) { die("[PIWI] - CreditCard Validator requires the credit card field name as third argument"); } $this->_code = "if (!isValidCreditCard(form." . $this->_field . ".value, form." . $cardtype . ".value) {\n"; $this->_code .= " alert ('" . $this->_error . "');\n"; $this->_code .= " form." . $this->_field . ".focus ();\n"; $this->_code .= " return false;\n"; $this->_code .= "}\n\n"; }
/** * Constructor * * @access public * @param string $field Field to validate * @param string $error Error to print */ function JSComboValidator($field, $error) { parent::__construct($field, $error); $this->_code .= "if (form." . $this->_field . ".type == \"select-one\" || "; $this->_code .= "form." . $this->_field . ".type == \"select-multiple\" || "; $this->_code .= "form." . $this->_field . ".type == \"select\") {\n"; $this->_code .= " if (form." . $this->_field . ".selectedIndex == -1) {\n"; $this->_code .= " alert ('" . $this->_error . "');\n"; $this->_code .= " form." . $this->_field . ".focus ();\n"; $this->_code .= " return false;\n"; $this->_code .= " }\n"; $this->_code .= " if (form." . $this->_field . ".options[" . $this->_field . ".selectedIndex].value == '') {\n"; $this->_code .= " alert ('" . $this->_error . "');\n"; $this->_code .= " form." . $this->_field . ".focus ();\n"; $this->_code .= " return false;\n"; $this->_code .= " }\n"; $this->_code .= "}\n\n"; }