开发者

Validation error placement in Bassistance

开发者 https://www.devze.com 2023-02-09 22:08 出处:网络
i\'m using Bassasistance jQuery validation and so far it seems to be great! I\'ve a quick question regarding the error placement.

i'm using Bassasistance jQuery validation and so far it seems to be great! I've a quick question regarding the error placement.

At the moment, as can be 开发者_高级运维seen below, I am targetting the <small> tag, which I also use as a hint for what the user should type into the field. If validation fails, I would like to replace the current hardcoded contents with the relevant message from the script. When validation fails it looks like it's just adding another <small> element under my own one

Any ideas would be great!

The page can be found online at http://www.st-patricks-day-2011.com/addlisting.asp

Here's the code that I am using

$("#paradeEventForm").validate({
  errorElement: "small",

  rules: {
    name: "required",
    description: "required",
    keywords: "required",
    address: "required",
    country: "required",
    eventDate: "required",
    websiteAddress: "required"
  },

  messages: {
    name: "Please enter a title for your Parade or Event",
    description: "Please enter a description for your Parade or Event",
    keywords: "Please enter some keywords that describe your Parade or Event",
    address: "Please enter the starting point of your Parade or Event",
    country: "Please enter the country where your Parade or Event is taking place",
    eventDate: "Please enter a date for your Parade or Event",
    websiteAddress: "Please enter the website address of you Parade or Event"
  }
});


If i understood your question, you can try replace the small content in the errorPlacement:

errorPlacement: function(error, element) {
    element.searchforyoutsmall.html(error;
},
0

精彩评论

暂无评论...
验证码 换一张
取 消