2012-03-02 98 views
0

之间我使用jQuery验证插件来验证我的形式。它工作正常,但问题是验证错误消息显示在标签和输入之间。请检查下面的截图jQuery验证错误消息没有显示在标签和输入

enter image description here

但我想将其显示在输入的右侧。

请您告诉我该怎么做?

感谢提前:)

对于我的CSS和HTML代码的形式请http://jsfiddle.net/6HmtE/1/

我使用的是 - http://bassistance.de/jquery-plugins/jquery-plugin-validation/

+0

,你可以在自己的jsfiddle的JavaScript,请? – SenorAmor 2012-03-02 20:05:16

+0

那个jsFiddle中没有JavaScript/jQuery。 – 2012-03-02 20:05:51

+0

感谢Goran Mottram和SenorAmor的回复。这里是新的链接http://jsfiddle.net/6HmtE/5/。 – 2012-03-02 20:17:29

回答

0

验证插件可以设置的位置你的错误消息与<label for="fieldId" class="error"> - 这里有一个演示这里显示如何可以将错误消息以不同的安排:http://jquery.bassistance.de/validate/demo/errorcontainer-demo.html

还有几个选项,您可以配置:

errorContainer: containerName, 
errorLabelContainer: $("jQuerySelectorForYourcontainer) 
0

float风格是不正确。尝试将其更改为right作为验证消息。

0

您的形式应该是这样的

<form id="form" name="form" method="post" action="index.html"> 
<h1>Sign-up form</h1> 
<p>This is the basic look of my form without table</p> 

<dl> <label for="name">Name </label> 
<input type="text" name="name" id="name" class="required" /> 
<?php echo form_error('name'); ?> 
<br /> 

<label for="company_name">Company Name </label> 
<input type="text" name="company_name" id="company_name" class="required" /> 
<?php echo form_error('name'); ?> 
<br /> 

<label for = 'email'>Email</label> 
<input type="text" name="email" id="email" class="required email" /> 
<?php echo form_error('name'); ?> 
<br /> 

<label for ='subject'>Subject</label> 
<input type="text" name="subject" id="subject" class="required" /> 
<?php echo form_error('name'); ?>      
<br /> 

<label for ='message'>Message</label> 
<textarea cols="8" rows="8" name = 'message'></textarea> 
<?php echo form_error('name'); ?> 
<br /> 


<input type="submit" name="submit"/> 
<div class="spacer"></div> 

</form> 
0

这应该做的伎俩:)

$("#myform").validate({ 
    errorPlacement: function(error, element) { 
    error.appendTo(element.parent("td").next("td")); 
    }, 
    //debug:true 
}); 
相关问题