Created
October 23, 2012 16:35
-
-
Save sipple/3939944 to your computer and use it in GitHub Desktop.
Time validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
jQuery(document).ready(function($){ | |
$('.datepicker').datepicker({ changeMonth: true, changeYear: true, minDate: '-1y', maxDate: '+3y'}); | |
$.validator.addMethod("time", function(value, element) { | |
return this.optional(element) || /^(([0-1]?[0-9])|([2][0-3])):([0-5]?[0-9])(:([0-5]?[0-9]))?$/i.test(value); | |
}, "Please enter a valid time."); | |
$("#post").validate({ | |
rules: { | |
time: "required time" | |
} | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment