I am using the Bootstrap 3 framework & jQuery validate plugin to show errors on a form field by displaying a 'green tick' image directly to the right of each form field - it works it just shows the image just under the field rather than to the right.
I am trying to simulate the following form on this demo http://alittlecode.com/files/jQuery-Validate-Demo/index.html
<div class="col-xs-10">
<div class="form-group">
<label for="inputFirstName" style="display: none;">First Name</label>
<?= form_input('first_name', '', "id='first_name' class='form-control {$error}'"); ?>
</div>
<div class="form-group">
<label for="inputLastName" style="display: none;">Last Name</label>
<?= form_input('last_name', '', "id='last_name' class='form-control {$error}'"); ?>
</div>
</div>
My CSS/JS is as follows:
<script type="text/javascript" src="/assets/js/includes/jquery.validate.min.js"</script>
<script type="text/javascript">
$(document).ready(function () {
$('#checkout-form').validate({
rules: {
first_name: {
minlength: 2,
required: true
},
email: {
required: true,
email: true
}
},
highlight: function (element) {
$(element).closest('.control-group').removeClass('success').addClass('error');
},
success: function (element) {
element.text('OK!').addClass('valid')
.closest('.control-group').removeClass('error').addClass('success');
}
});
});
</script>
<style type="text/css">
label.valid {
width: 16px;
height: 16px;
background: url('/assets/images/icons/tick.png') center center no-repeat;
display: inline-block;
text-indent: -9999px;
}
label.error {
font-weight: bold;
color: red;
padding: 2px 8px;
margin-top: 2px;
}