2011-02-10 167 views
1

我使用Bassasistance jQuery验证,并且到目前为止它似乎很棒!我有一个关于错误位置的快速问题。jquery验证,错误放置

目前,正如下面可以看到的,我正在瞄准[小]标签,我也用它作为提示用户应该在字段中输入的内容。如果验证失败,我想用脚本中的相关消息替换当前的硬编码内容。当验证失败时,它看起来就像在我自己​​的平台上添加另一个元素

任何想法都会很棒!

页可以在http://www.st-patricks-day-2011.com/addlisting.asp

网上找到这里的,我使用

$("#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" 
    } 
}); 

欢呼 Decbrad

+0

你可以在服务器端脚本中用默认数据预填充表单字段,这将被视为默认数据。您也可以创建一个添加事件来更改默认值点击 – 2011-02-10 10:59:25

回答

0

如果我理解你的问题的代码,你可以尝试更换小内容在errorPlacement中:

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

嗨马库斯,谢谢!是的,完全正确!如果小元素包含提示并且需要验证消息,则现有消息应该被错误消息覆盖。我试图包含您建议但没有太多运气的代码!完成新手!你能解释一下还是在网上建议一个教程?太感谢了! D B – decbrad 2011-02-10 18:38:39