Jquery form verification, jquery form
1, first need to import js package and css package: http://download.csdn.net/detail/l294333475/7816951
2. index. jsp (test page)
<% @ Page language = "java" import = "java. util. * "pageEncoding =" UTF-8 "%> <% String path = request. getContextPath (); String basePath = request. getScheme () + ": //" + request. getServerName () + ":" + request. getServerPort () + path + "/"; %> <! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN"> Validate. js: (you can modify it as required)
$ (Document ). ready (function () {/*** validation information validation */jQuery ("# checkInfoForm "). validationEngine ();/*** user-defined information verification */jQuery ("# applyForm "). validationEngine ({'m M _ error_messages ': {' # txtKeyNum ': {'Min': {'message': "Enter at least one electronic key "}}, '# fileseal': {'required': {'message': "upload a seal image file" }},' # filesign': {'required ': {'message': "upload a signed image file "}}}});});
Jquery Form Verification plug-in
ByteRange: [, 'utf-8']. This rule is not found in the API. It should be your custom validation rule. Make sure that it is successfully defined:
JQuery. validator. addMethod ("byteRange", function (value, element, param ){
//
}, $. Validator. format ("..."));
During the test, I took the byteRange: [3, 15, 'utf-8'] sentence and verified it successfully.
Jquery verifies the form and submits it if it fails to pass the verification. How can this problem be solved?
First: submit with js, submit-button
Second. Check it.
$ ("# TxtName"). blur (function () {-- this sentence is☞The event triggered when the text box loses focus, right.
Onsubmit = "return blur ()"--☞Method
Changed to function blur (){
Then copy the verification code.
}
Then. $ ("# txtName"). blur (function () {blur () ;});