This repository has been archived by the owner on Oct 23, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
validation.min.js
13 lines (13 loc) · 2.7 KB
/
validation.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
//---------------------------------------------------------------------------------
// Dado Validators, Copyright 2013 roydukkey.
// Dual licensed under the MIT (http://www.roydukkey.com/mit) and
// GPL Version 2 (http://www.roydukkey.com/gpl) licenses.
//---------------------------------------------------------------------------------
function ValidatorGetValue(a){a=document.getElementById(a);return"string"==typeof a.value?"type"in a&&"file"==a.type?a.value.replace(/^.*[\\\/]/,""):a.value:ValidatorGetValueRecursive(a)}
function ValidatorUpdateDisplay(a){"None"!=a.display&&(a.style.visibility=a.style.display="",a.className=a.className.replace(a.invalidClassName,"").replace(/^\s+|\s+$/g,""),!a.isvalid||-1<navigator.userAgent.indexOf("Mac")&&-1<navigator.userAgent.indexOf("MSIE"))&&(a.className+=(a.className?" ":"")+a.invalidClassName)}
function RegularExpressionValidatorEvaluateIsValid(a){var b=ValidatorGetValue(a.controltovalidate);if(0==ValidatorTrim(b).length)return!0;a=RegExp(a.validationexpression,a.expressionoptions).exec(b);return null!=a&&b==a[0]}
function LengthValidatorEvaluateIsValid(a){var b=~~a.minimumlength,c=~~a.maximumlength;if(""!=ValidatorGetValue(a.controltovalidate)&&(0>=c&&0<b||b<=c)){if(0<b&&ValidatorGetValue(a.controltovalidate).length<b)return a.innerHTML="<span>"+a.minimumerrormessage+"</span>",!1;if(0<c&&ValidatorGetValue(a.controltovalidate).length>c)return a.innerHTML="<span>"+a.maximumerrormessage+"</span>",!1}return!0}
function TypeValidatorEvaluateIsValid(a){var b=ValidatorGetValue(a.controltovalidate);if(null==b)return!0;switch(a.type){case "Boolean":return"true"==b.toLowerCase()||"false"==b.toLowerCase();case "Byte":return 0<=+b&&255>=+b;case "Char":return 1==b.length;case "Decimal":return b=b.replace(",",""),-7.922816251426434E28<=+b&&7.922816251426434E28>=+b;case "Double":return b=b.replace(",",""),-1.7976931348623157E308<=+b&&1.7976931348623157E308>=+b;case "Int16":return-32768<=+b&&32767>=+b;case "Int64":return-9223372036854775E3<=
+b&&9223372036854775E3>=+b;case "SByte":return-128<=+b&&127>=+b;case "Single":return-3.402823E38<=+b&&3.402823E38>=+b;default:return-2147483648<=+b&&2147483647>=+b}}
function RequiredFieldValidatorEvaluateIsValid(a){if("checkbox"===a.validatefor)return document.getElementById(a.controltovalidate).checked;if("checkboxlist"===a.validatefor){a=document.getElementById(a.controltovalidate).getElementsByTagName("input");for(var b=0;b<a.length;)if(a[b++].checked)return!0;return!1}return ValidatorTrim(ValidatorGetValue(a.controltovalidate))!=ValidatorTrim(a.initialvalue)}
function ValidateOnLoad(){Page_InvalidControlToBeFocused=null;if("undefined"==typeof OnLoad_Validators)return!0;for(var a=0;a<OnLoad_Validators.length;a++)ValidatorValidate(OnLoad_Validators[a])};