Created
February 2, 2017 19:35
-
-
Save FabianoFaria/ad66489a8c4fc10599c7b72724c14532 to your computer and use it in GitHub Desktop.
Data x maior que yy, formato 'yyyy/mm-dd'
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
/* | |
* Valida se a data fina é maior que a data inicio | |
*/ | |
jQuery.validator.addMethod("greaterThan", | |
function(value, element, params) { | |
var temp = value.split("/"); | |
var temp2 = $(params).val().split("/"); | |
if (!/Invalid|NaN/.test(new Date(temp[2], (temp[1] - 1), temp[0]))) { | |
return new Date(temp[2], (temp[1] - 1), temp[0]) > new Date(temp2[2], (temp2[1] - 1), temp2[0]); | |
} | |
return isNaN(value) && isNaN($(params).val()) | |
|| (Number(value) > Number($(params).val())); | |
},'Must be greater than {0}.'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment