我想验证一个需要在格式中接受ony的文本框 日期在YYYY-MM-DD HH:MM使用
<!DOCTYPE html>
<html>
<body>
<form action="/action_page_post.php" method="post">
<input type="text" name="fname" required>
<input type="submit" value="Submit">
</form>
<p>If you click submit, without filling out the text field,
your browser will display an error message.</p>
</body>
</html>
如果某些内容不是所述格式,它应该变为红色或发光。
答案 0 :(得分:4)
这将测试
boom ()
&#13;
function isValid(str) {
var isPattern = /^20[1-9][0-9]-[0-1][0-2]-[0-3][0-9] [0-2][0-4]:[0-5][0-9]$/.test(str);
if (!isPattern) return false;
var d = new Date(str);
return (!isNaN(d));
}
window.onload=function() {
document.querySelector("input[name=date]").onkeyup=function() {
var val = this.value;
this.className = isValid(val)?"":"glow"
}
}
&#13;
.glow { background-color:pink }
&#13;
答案 1 :(得分:1)
如何掩盖呢?
ISO Date: <input type="text" value="" data-mask="____-__-__ __:__"/>
&#13;
string data = new WebClient().DownloadString("http://www.myfxbook.com/rss/forex-economic-calendar-events");
XDocument xdoc = XDocument.Parse(data);
//selecting table rows
var tablerows = from tr in xdoc.Descendants("tr")
select tr;
//extarct the headers
var headings = from th in tablerows.Descendants("th")
select th.Value;
//extract column data
var values = from td in tablerows.Descendants("td")
select td.Value;
//Creating pairs
var pairs = Enumerable.Zip(headings, values, (name, value)
=> new Tuple<string, string>(name, value));
foreach(var item in values)
{
Console.WriteLine(item);
}
Console.ReadLine();
&#13;