嗨即時通訊使用codeigniter來生成一個窗體錯誤只顯示如果有一個錯誤,該字段我使用twitter-bootstrap的樣式,所以我需要一種方法來添加一類的錯誤將div(class =「clear fix」)和輸入if(span class =「help-inline」)作爲子項存在。如果孩子存在,將類添加到家長
寧願不使用查詢,以便正常降解,但任何選項將是一件好事
任何幫助將是巨大的。希望是有道理的。代碼是感謝下面
<?php echo form_open('login'); ?>
<fieldset>
<div class="clearfix">
<?php echo form_label('Email Address: ', 'email_address');?>
<div class="input"><?php echo form_input('email_address', set_value('email_address'), 'id="email_address" class="xlarge" autofocus ');?>
<?php echo form_error('email_address', '<span class="help-inline">', '</span>'); ?>
</div>
</div><!-- /clearfix -->
<div class="clearfix">
<?php echo form_label('Password: ', 'password');?>
<div class="input"><?php echo form_input('password', '', 'id="password" class="xlarge"');?>
<?php echo form_error('password', '<span class="help-inline">', '</span>'); ?>
</div>
</div><!-- /clearfix -->
<div class="actions">
<?php echo form_submit('submit', 'Login', 'class="btn primary"'); ?>
</div>
</fieldset>
<?php echo form_close(); ?>
呈現的HTML(如果被觸發錯誤)
<form action="http://unetics.site/index.php/login" method="post" accept-charset="utf-8">
<div style="display:none">
<input type="hidden" name="csrf_test_name" value="c0856f469b1f498480881a8512042ccf" />
</div>
<fieldset>
<div class="clearfix">
<label for="email_address">Email Address: </label>
<div class="input">
<input type="text" name="email_address" value="" id="email_address" class="xlarge" autofocus />
<span class="help-inline">The Email Address field is required.</span> </div>
</div><!-- /clearfix -->
<div class="clearfix">
<label for="password">Password: </label>
<div class="input"><input type="text" name="password" value="" id="password" class="xlarge" />
<span class="help-inline">The Password field is required.</span>
</div>
</div><!-- /clearfix -->
<div class="actions">
<input type="submit" name="submit" value="Login" class="btn primary" />
</div>
</fieldset>
</form>
也不知道這是否改變了任何東西,但我用少生成我的css –
顯示呈現的HTML; php(服務器端)與JavaScript(客戶端)完全無關。 –