Created
April 22, 2014 14:06
-
-
Save lajunta/11180560 to your computer and use it in GitHub Desktop.
javascript time format yyyy-mm-dd hh:ss validation
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
var patt=/2\d{3}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])[\s+](0[0-9]|1[0-9]|2[0-3]):(0[0-9]|[1-5][0-9])/; | |
$(document).ready(function(){ | |
$("#settings").submit(function(){ | |
var tk=true; | |
$("#settings input[type=text]").each(function(){ | |
result = patt.exec($(this).val()); | |
if(result==null){ | |
var txt=$(this).parent().prev("td").text(); | |
alert(txt+"格式不对"); | |
tk=false; | |
return false; | |
} | |
}); | |
return tk; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment