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

WBOY
Release: 2016-06-21 08:49:34
Original
1224 people have browsed it

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");			}		}
Copy after login

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

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template