2012-03-02 37 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 
}); 
相關問題