I have a text box in a form to enter time and I use to check the validation using jquery. But now I want to check the validation of the text box using the codeigniter’s built-in validation system. Would you please kindly tell me how to validate time input using codeigniter’s built-in validation system?
Here’s the code how I use to do it using jquery:
<script type="text/javascript">
$().ready(function() {
$.validator.addMethod("time", function(value, element) {
return this.optional(element) || /^(([0-1]?[0-2])|([2][0-3])):([0-5]?[0-9])\s(a|p)m?$/i.test(value);
}, "Enter Valid Time");
$("#theForm").validate({
rules: {
time: "required time",
},
});
});
</script>
And here is the html
<input class="time" type="text" name="time1" size="15">
Something like this perhaps
and a callback: