Codeigniter Form Validation - Showing Errors Individually problems
Tags: php,html,css,codeigniter
Problem :
My form is in table and I try to write error message of form validation next to input space. (I put it in the third column)
the problems is the form_error() function that make more line-height between row in table. How should I do? because if I use CSS, it will make the "before error message occurred's line-height" wrong. Do I need to write the if-else of before-after button submit situation?
<table>
<tr>
<td>Username : </td>
<td><input type="text" name="username" value="<?php echo set_value('username'); ?>"/></td>
<?php
if($this->input->post("btn") == null)
{
echo "<td><span style='font-size: 10px;color:red'>ขั้นต่ำ 6 ตัวอักษร</span></td>";
}
else
{
echo "<td><span style='font-size:10px;color:red;'>" . form_error('username') ."</span></td>";
}
?>
</tr>
<tr>
<td>Password : </td>
<td><input type="password" name="pass" value=""/></td>
<?php
if($this->input->post("btn") == null)
{
echo "<td><span style='font-size: 10px;color:red'>ขั้นต่ำ 6 ตัวอักษร</span></td>";
}
else
{
echo "<td><span style='font-size:10px;color:red;'>" . form_error('pass') ."</span></td>";
}
?>
</tr>
<tr>
<td>ยืนยัน Password : </td>
<td><input type="password" name="pass_confirm" value=""/></td>
<td><span style="font-size:10px;color:red;"><?php echo form_error('pass_confirm');?></span></td>
</tr>
<tr>
<td>Email : </td>
<td><input type="text" name="email" value="<?php echo set_value('email'); ?>"/></td>
<td><span style="font-size:10px;color:red;"><?php echo form_error('email');?></span></td>
</tr>
<tr>
<td colspan="2"><span style="font-size: 10px;color:red;">กรุณากรอกเบอร์มือถือ เพื่อรับ Code ยืนยันการสมัคร (ตัวอย่างเบอร์มือถือ 08xxxxxxxx)</span></td>
</tr>
<tr>
<td>เบอร์มือถือ : </td>
<td><input type="text" name="phone" value="<?php echo set_value('phone'); ?>"/></td>
<td><span style="font-size:10px;color:red;"><?php echo form_error('phone');?></span></td>
</tr>
<tr>
<td>กรอกรหัสภาพ :</td>
<td>
<?php echo $captcha['image']; ?>
<br>
<input type="text" autocomplete="off" name="userCaptcha" placeholder="Enter above text" value="<?php if(!empty($userCaptcha)){ echo $userCaptcha;} ?>" />
<?php echo form_error('userCaptcha','<p style="font-size:10px;color:red">','</p>'); ?>
</td>
</tr>
</table>
Solution :
You can load error delimiters for all the errors in one place,in relevant controller's function, need not to define them separately,
you can control the error message height and styles there
$this->form_validation->set_error_delimiters('<span style="font-size: 10px;color:red">', '</span>');
and need not to use 'if-else' in 'form-error' so use
<tr>
<td>Username : </td>
<td><input type="text" name="username" value="<?php echo set_value('username'); ?>"/>
<?php
// if there is validation error, it shows here
echo form_error('username');
?>
</td>
</tr>
CSS Howto..
.to-top { border-right: 60px solid transparent; border-left: 60px solid transparent; border-bottom: 60px solid black; position: fixed; bottom: 0; left: 50%; right: 50%; transform: translateX(-50%); } .to-top span { height:...
Use thead tr td a { color: white; } thead tr td a:hover { color: white; } thead tr td a:visited { color: white; } thead tr td a:active {...
i have made it by regex ! yes i have parsed html with regex ... only me and chuck Norris can do it lol... After that i have cleaned the...
You can't directly 'count' total numbers of elements in CSS, so there's no way to only apply the class if there's 2 or more divs (you'd need JavaScript for that)....
You have a few typos in your code, otherwise it kinda works. You can help reduce these and also improve performance by stashing all your lookups in variables. The logic...
This probably is not an answer yet, but if you can address our confusion, I can update this. In this FIDDLE I've: Tried to give an example of the functionality...
You should use mouseleave instead of mouseOut as mouseOut will get triggered even if you hover over the a or p which is inside #meist. $(function(){ $("#meist").mouseleave(function () { $("#submeist").hide();...
They all need their own selectors, but you can separate them with ,: .a:hover, .a:hover ~ .b, .a:hover ~ .c { stroke: red; } (Note that ~ is “sibling after”...
Don't use floating blocks if you don't want them to wrap. Sounds to me like you want table-like behavior: .item_row { display:table; } .item_row > * { display:table-cell; vertical-align:top; }...
Use a percentage: background-position: 50% 50% will center the background image.
Use the same style for the normal and hover effect. That way the link will have the same style when you hover it, as when you don't. You don't disable...
The reason your divs are overlapping is because your using percent to position them. I would recomend not using percentage at all when it comes to positioning the divs and...
The stylesheet will be loaded using wp_register_style probably in the functions.php
Build a Demo as per the trick given at QuirksMode. Read it for an explanation. HTML <div class="fileinputs"> <input type="file" class="file" /> <div class="fakefile"> <a href="#" class="button">Browse</a> </div> </div> CSS...
If you don't mind putting all you CSS into one stylesheet you could do this: Place this in the <head> tag of your HTML: <link id="ss" rel="stylesheet" type="text/css" href="norm.css" />...
This can be solved in many ways, here's one of these solutions: Give the #body the full original background-image of the page, which includes the falling leaf. With the right...
you can use following <style type="text/css"> table { page-break-inside:auto } tr { page-break-inside:avoid; page-break-after:auto } </style> refer for details and also refer http://forums.sforce.com/t5/forums/forumtopicprintpage/board-id/Visualforce/message-id/31977/print-single-message/false/page/1...
It's referenced in a CSS file. Check http://www.shannabarnard.com/css/materialize.css. There is a font called "Material-Design-Icons" included. The CSS classes are mapped to this font using pseudo attributed as :before. .mdi-content-archive:before {...
To avoid a costly run through the entire dom, do this: $("a.page-numbers").click(function() { $(this).addClass('current').siblings().removeClass('current'); }); ...
Your <div>s are surrounded by some more unique parents, so you can simply do: .span6 .td_block4 { background-color: #f00; } .span4 .td_block4 { background-color: #000; } Sometimes, it's not about...
Transitions work in both directions automatically. The problem you are experiencing is that border-style is not a property that can be animated so it changes instantly. This means that when...
If you are using the Views module you can assign a class to those fields from the Views interface: and then apply display: inline-block or float:left to that class to...
Display your image through the CSS using background-image and apply the extra property background-size to make it fill the container. Here’s a fiddle. HTML <div class="cover" id="1"> <a href="Articles/boy.html"> <span...
In general it is not possible to select elements based on their next sibling. In your specific case, you can use ul li a:not(:last-child)::after, because it happens that your anchors...
Try something like that: store.on('add', function() { var els = Ext.select('.price-fall', this.getEl()); els.each(function(el) { el.removeCls('price-fall'); }); els = Ext.select('.price-rise', this.getEl()); els.each(function(el) { el.removeCls('price-rise'); }); }, grid, { delay: 2000 });...
What you call margin is perimeter of a polygon you can set the color of the border of a poligon this way // Define the LatLng coordinates for the polygon's...
Google is your best friend, there are many free resources, but check out lynda.com, it has tons of videos and articles that will help you learn html, css, javascript, php....
Sorry, no pure CSS solution. Use jQuery... You want to attach an event to the window.resize. Caution is that the window.resize refreshes constanstanly, so a little extra function is needed...
See where he says he's stripped the vendor prefixes out of his CSS to keep things clean? I'm betting that's your problem. Some of those CSS properties aren't fully standard,...
Is there any reason it has to be with flexbox? If you don't mind using an alternative method this tutorial will show you exactly how to create masonry-style layouts. Here's...