Home  >  Article  >  Web Front-end  >  js验证时间格式_html/css_WEB-ITnose

js验证时间格式_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-21 08:49:341217browse

js验证时间格式 为 (09:00-18:00),这种怎么做,只需验证时间就行。


回复讨论(解决方案)

function validate_time(){			var time = $("#time").val();			var pattern = /^[0-9]{2}:[0-9]{2}-[0-9]{2}:[0-9]{2}$/;			if(time.match(pattern)){				alert("1");			}else{				alert("2");			}		}

正则表达式。     09:00-18:00

楼上的正则还可优化一下, 因为 99:99-99:99 也是 1....

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn