Created
February 25, 2015 15:09
-
-
Save thyagorafaell/35b1d7a994adf10f61e9 to your computer and use it in GitHub Desktop.
Some useful jQuery Validation methods.
This file contains hidden or 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
| (function(moment, $) { | |
| $.validator.addMethod('datetime', function(value, element) { | |
| if (value === '__/__/__ __:__' || value === '') { | |
| return true; | |
| } | |
| return moment(value, 'DD/MM/YYYY HH:mm', true).isValid(); | |
| }, ''); | |
| $.validator.addMethod('date', function(value, element) { | |
| if (value === '__/__/__ __:__' || value === '') { | |
| return true; | |
| } | |
| return moment(value, 'DD/MM/YYYY HH:mm').isValid(); | |
| }, ''); | |
| $.validator.addMethod('time-report', function(value, element) { | |
| if (value === '__:__' || value === '') { | |
| return true; | |
| } | |
| return moment(value, 'h:mm').isValid(); | |
| }, ''); | |
| $.validator.addMethod('time', function(value, element) { | |
| if (value === '__:__' || value === '') { | |
| return true; | |
| } | |
| return moment(value, 'HH:mm').isValid(); | |
| }, ''); | |
| }(moment, window.jQuery)); |
This file contains hidden or 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
| !function(_,t){t.validator.addMethod("datetime",function(t){return"__/__/__ __:__"===t||""===t?!0:_(t,"DD/MM/YYYY HH:mm",!0).isValid()},""),t.validator.addMethod("date",function(t){return"__/__/__ __:__"===t||""===t?!0:_(t,"DD/MM/YYYY HH:mm").isValid()},""),t.validator.addMethod("time-report",function(t){return"__:__"===t||""===t?!0:_(t,"h:mm").isValid()},""),t.validator.addMethod("time",function(t){return"__:__"===t||""===t?!0:_(t,"HH:mm").isValid()},"")}(moment,window.jQuery) |
This file contains hidden or 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
| (function(moment, $) { | |
| $.validator.addMethod('datetime', function(value, element) { | |
| if (value === '__/__/__ __:__' || value === '') { | |
| return true; | |
| } | |
| return moment(value, 'MM/DD/YYYY HH:mm', true).isValid(); | |
| }, ''); | |
| $.validator.addMethod('date', function(value, element) { | |
| if (value === '__/__/__ __:__' || value === '') { | |
| return true; | |
| } | |
| return moment(value, 'MM/DD/YYYY HH:mm').isValid(); | |
| }, ''); | |
| $.validator.addMethod('time-report', function(value, element) { | |
| if (value === '__:__' || value === '') { | |
| return true; | |
| } | |
| return moment(value, 'h:mm').isValid(); | |
| }, ''); | |
| $.validator.addMethod('time', function(value, element) { | |
| if (value === '__:__' || value === '') { | |
| return true; | |
| } | |
| return moment(value, 'HH:mm').isValid(); | |
| }, ''); | |
| }(moment, window.jQuery)); |
This file contains hidden or 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
| !function(_,t){t.validator.addMethod("datetime",function(t){return"__/__/__ __:__"===t||""===t?!0:_(t,"MM/DD/YYYY HH:mm",!0).isValid()},""),t.validator.addMethod("date",function(t){return"__/__/__ __:__"===t||""===t?!0:_(t,"MM/DD/YYYY HH:mm").isValid()},""),t.validator.addMethod("time-report",function(t){return"__:__"===t||""===t?!0:_(t,"h:mm").isValid()},""),t.validator.addMethod("time",function(t){return"__:__"===t||""===t?!0:_(t,"HH:mm").isValid()},"")}(moment,window.jQuery) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment