Easyui Check Package

Source: Internet
Author: User
Tags extend
$ (function () {/************************* can be called directly by the checksum method ***************************///is not an empty function Notnull = function (ID, msg) {$
	(' # ' +id). Validatebox ({required:true, missingmessage:msg});
		}//Repeat function Reapet = function (ID, re_id, msg) {id = ' # ' +id;
	$ (' # ' +re_id). Validatebox ({validtype: "reapet[" "+id+" ', ' "+msg+" '] "});
	};
	Number = function (ID, msg) {$ (' # ' +id). Validatebox ({validtype: ' number[' ' +msg+ ' "] '});
	};
	Mobile number CellPhone = function (ID, msg) {$ (' # ' +id). Validatebox ({validtype: ' cellphone[' ' +msg+ ' "] '});
	};
	Phone Number phone = function (ID, msg) {$ (' # ' +id). Validatebox ({validtype: ' phone[' ' +msg+ ' "] '});
	};
	email = function (id,msg) {$ (' # ' +id). Validatebox ({validtype: ' email ', invalidmessage:msg});
	};
	URL url = function (ID, msg) {$ (' # ' +id). Validatebox ({validtype: ' URL ', invalidmessage:msg});
	};
	IP IP = function (ID, msg) {$ (' # ' +id). Validatebox ({validtype: ' ip[' ' +msg+ ' "] '});
	}; /** * Submit to BackgroundUniqueness Check * @param ID: Verify the Id,url of the element: the submitted address, paramname: The parameter name of the incoming value */unique = function (id, URL, paramname) {$ (' # ' +id).
	Validatebox ({validtype: ' unique[' "' +url+ '", "' +id+ '", "' +paramname+ '"] '});
	}; Commit, the data is invalid when the block commits form = function (id, URL) {$ ("#" +id). Form ({url:url, onsubmit:function () {return $ (this).
			Form (' Validate ');
			}, Success:function (data) {alert (data);
	}
	   });
	}; /************************* NOT NULL check required= "true" ********************************///Add required= "true" to HMTL tag You can make a null check of $ ("*"). each (function () {if ($ (). attr (' required ')} {$ (this). Validatebox ({required:true, missin
		Gmessage: ' cannot be empty '});
	}
	}); When using the struts tag, add the attribute required= "true" can not be null verified by the following code implementation: The Struts label requires a label of $ (' span '). each (function () {//Traverse all span tags, Verify that the class= "required" if ($ (this) is provided. attr (' class ') = = ' Required ') {$ ("#" +$ (This). Parent (). attr (' for '). Validatebox ({R
		Equired:true, Missingmessage: ' cannot be empty '});
	
	}
	}); /******Custom Method ********************************//** * Custom Calibration method (check two passwords are the same) * @param param the ID of the password box entered for the first time *
				@call repeat[' #id '] */$.extend ($.fn.validatebox.defaults.rules,{reapet: {validator:function (value, param) { 
				var pwd = $ (param[0]). attr (' value ');
				if (pwd! = value) {return false;
			} return true;
		
	}, Message: ' {1} '}};
           Use regular for digital checksum $.extend ($.fn.validatebox.defaults.rules, {number: {validator:function (value, param) { Return/^-? (?:/ d+|/d{1,3} (?:,/d{3}) +) (?:/.
       /d+)? $/.test (value);
	}, message: ' {0} '}}; Mobile number $.extend ($.fn.validatebox.defaults.rules,{cellPhone: {validator:function (value, param) {return/^0{0,1} (
			13[4-9]|15[7-9]|15[0-2]|18[7-8]) [0-9]{8}$/.test (value);
	}, message: ' {0} '}}; /** * Phone number * Match format: 11-digit Mobile phone number * 3-4-digit area code, 7-8-digit live number, 1-4 poorly transposition machine number * such as: 12345678901, 1234-12345678-1234 */$.extend ($.fn.validat ebox.defaults.rules,{Phone: {validator:fUnction (value, param) {return/(/d{11}) |^ ((/d{7,8}) | ( /D{4}|/D{3})-(/d{7,8}) | (/d{4}|/d{3})-(/d{7,8})-(/d{4}|/d{3}|/d{2}|/d{1}) |
			(/d{7,8})-(/d{4}|/d{3}|/d{2}|/d{1})) $/.test (value);
	}, message: ' {0} '}}; IP checksum $.extend ($.fn.validatebox.defaults.rules,{IP: {validator:function (value, param) {return/^ (2[0-4]/d|25 [0-5]| [01]?/d/d?] /.) {3} (2[0-4]/d|25[0-5]| [01]?/d/d?]
			$/.test (value);
	}, message: ' {0} '}}; Uniqueness Check $.extend ($.fn.validatebox.defaults.rules,{unique: {validator:function (value, param) {value = $ (' # ' +PA
				RAM[1]). attr (' value '); $ (' # ' +param[1]). Load (param[0]+ "?"
						+param[2]+ "=" +value, function (ResponseText, textstatus, XMLHttpRequest) {if (responsetext)///background return TRUE or False	
				return true;
				});
			return false;
}, message: ' User name already exists '}}; });

Html:

		<mce:script type= "Text/javascript" src= "Javascripts/functionpoint/validate.js" mce_src= "javascripts/
				Functionpoint/validate.js "></mce:script> <mce:script type=" Text/javascript "><!--$ (function () {
				Notnull (' Ages ', ' age cannot be empty ');
				Reapet (' Password ', ' Repassword ', ' two inputs not identical ');
				Number (' Age ', ' can only be numeric ');
				CellPhone (' phone ', ' Mobile number format is incorrect ');
				Phone (' phone ', ' phone number is not formatted correctly ');
				Email (' Email ', ' email ' is not properly formatted ');
				Unique (' username ', ' unique.html ', ' name ');
			Form (' form ', ' user_regist.html ');
		
}); --></mce:script>  


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.