Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lajunta/11180560 to your computer and use it in GitHub Desktop.
Save lajunta/11180560 to your computer and use it in GitHub Desktop.
javascript time format yyyy-mm-dd hh:ss validation
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