JQuery Validate Verify display error prompt location

Source: Internet
Author: User


Validate multiple elements with the same name value:

$ (". Send"). Click (function () {var a = 0; var b = 0; var c = 0; var d = 0; Reset the Name Value $ ("input[name^= ' ContactName '"). each (function () {$ (this) . attr (' name ', ' contactname[' + A + ') '); a++; }) $ ("input[name^= ' Contacttel ')". each (function () {$ (this). attr (' n Ame ', ' contacttel[' + B + '] '); b++; }) $ ("input[name^= ' Position ')". each (function () {$ (this). attr (' Nam E ', ' position[' + C + '] '); C + +; }) $ ("input[name^= ' Email ']"). each (function () {$ (this). attr (' name ', ' email[' + D + '] '); d++; }) $ ("input[name^= ' ContactName ')". each ( Function () {$ (this). Rules ("Add", {required:true, messages: {required: "Please fill in the Contact"},}); $ (this). Rules ("Add", {maxlength:50, messages: {maxlength: "The maximum length of the contact cannot be greater than 50"},}); }) $ ("input[name^= ' Contacttel ')". each (function () {$ (this). Rules (" Add ", {required:true, messages: {required:" Please fill in the contact information "},}); $ (this). Rules ("Add", {maxlength:50, messages: {maxlength: "The maximum length of a contact cannot be greater than 50"}); $ (this). Rules ("Add", {phonecheck:true, messages: {phonecheck: "Please fill in your contact information correctly"}); }) $ ("input[name^= ' Position ')". each (function () {$ (this). Rules ("Ad D ", {required:true, messages: {required:" Please fill in the title "},}); }) $ ("input[name^= ' Email ']"). each (function () {$ (this). Rules ("Add", {mailcheck:true, messages: {mailcheck: "Please fill in the correct message format"},}); $ (this). Rules ("Add", {required:true, messages: {required: "Please fill in the contact e-mail"},}); }) $ ("#mainform"). Submit (); $ (this). attr (' disabled ', true); if (!$ ("#mainform"). Valid ()) {$ (this). attr (' disabled ', false); } }) })
:

  

Show element Position:
1 $ ("#mainform"). Validate ({2 errorplacement:function (Error, Element) {3 if (Element.parent (). Hasclass ("Input-group")) {4 element.parent (). After (error);5 }6 Else7 element.after (Error)8 },9 errorplacement:function (Error, Element) {Ten error.appendto (Element.parent ());//directly after the error message is added to the validation element · One }, A rules: { - CustomerName: { - Required:true, the maxlength:50, - Remote: { - URL: '/crm/customer/checkcustomname ', - type: ' Post ', + data: { - customername:function () {return $ ("#CustomerName"). Val ()}, + id:function () A { at if ($ ("#Id"). val () = = undefined) { - return 0; - } else { - return $ ("#Id"). Val (); - } - } in } - } to }, + ownerid: { - required:true the }, * customertype:{ $ required:truePanax Notoginseng }, - address:{ the Required:true, + maxlength:100 A }, the Industryid: { + required:true - }, $ Capital : { $ Number:true, - min:0.001, - Maxlength:8 the } - },Wuyi messages: { the CustomerName: { - Required: ' Please enter the customer name ', Wu maxlength: ' Customer name is the maximum length of - Remote: ' Customer name cannot be duplicated ' About }, $ CustomerType: { - Required: ' Please select customer type ' - }, - Address: { A Required: ' Please enter an address ', + maxlength: ' Customer name maximum length is ' the }, - ownerid: { $ Required: ' Please select a docking person ' the }, the Industryid: { the Required: ' Please select industry ' the }, - Capital : { in number: ' Registered capital must be digital ', the min: ' Minimum registered capital of 10 Yuan ', the maxlength: ' Maximum registered capital is 8 bits ' About } the } the});

JQuery Validate Verify display error prompt location

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.