js 报错“未结束的字符串变量” 就一个简单的正则表达式字符串而已啊,求救啊! alert("请输入正确的日期格式!,例如:2009-01-01。\r\n 或从时间列表中选择日期。); // 没有结束冒号!改为alert("请输入正确的日期格式!,例如:2009-01-01。\r\n 或从时间列表中选择日期。"); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 alert("请输入正确的日期格式!,例如:2009-01-01。\r\n 或从时间列表中选择日期。); 这一行没有结束字符串 alert("请输入正确的日期格式!,例如:2009-01-01。\r\n 或从时间列表中选择日期。"); 是这个问题,LZ就晕掉去吧! 脚本错主要是丢了冒号!正则可以用,但似乎也不太正确。L@_@K<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> new document </title> <meta name="generator" content="editplus" /> <meta name="author" content="" /> <meta name="keywords" content="" /> <meta name="description" content="" /><script language="javascript" type="text/javascript"> function checkDate() { var strDate = document.getElementById("txtStrDate").value; // 这个正则只能匹配以 1800-1999 开头滴东东,不一定是日期噢! var result=strDate.match(/^1[8-9]\d{2}/); if(result==null) { // 提示信息末尾滴冒号丢了,已补上! alert("请输入正确的日期格式!,例如:2009-01-01。\r\n 或从时间列表中选择日期。"); } else { alert("符合您的要求"); } }</script> </head> <body> <input type="text" id="txtStrDate" value="1989haha" /> <input type="button" value="check date" onclick="checkDate();" /> </body></html> 调试通过!<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> new document </title> <meta name="generator" content="editplus" /> <meta name="author" content="" /> <meta name="keywords" content="" /> <meta name="description" content="" /> </head> <body> <script type="text/javascript"> function checkDate() { var strDate = document.getElementById("txtStrDate").value; var result=strDate.match(/^1[8-9]\d{2}/); if(result==null) { alert("请输入正确的日期格式!,例如:2009-01-01。\r\n 或从时间列表中选择日期。"); } else { alert("符合您的要求"); } } </script> <input id="txtStrDate" type="text" value="123" /><input id="btn" type="button" value="验证" onclick="checkDate() " /> </body></html> ASP.NET 中关于递归的问题 谁帮我看下这串代码的意思! 如何将html中JavaScript中某一变量的值传递到下一个js文件中 怎么做日期相减,得出年份 protype.js 中Enumerable中调用了iterator函数,这个函数在哪定义,有什么作用 js 时间戳转换为日期格式 谁帮我解密JScript.Encode??谢谢 高分求教关于层的问题!!! 请教各位高手,有没有可能让javascript打开一个Excel,同时传给这个文件参数? 有没有方法将Gridview 里的数值用js动态截取小数点后2位 调用JS出错 Easy CalenDar V1.0
这一行没有结束字符串
正则可以用,但似乎也不太正确。
L@_@K
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<script language="javascript" type="text/javascript">
function checkDate()
{
var strDate = document.getElementById("txtStrDate").value;
// 这个正则只能匹配以 1800-1999 开头滴东东,不一定是日期噢!
var result=strDate.match(/^1[8-9]\d{2}/);
if(result==null)
{
// 提示信息末尾滴冒号丢了,已补上!
alert("请输入正确的日期格式!,例如:2009-01-01。\r\n 或从时间列表中选择日期。");
}
else
{
alert("符合您的要求");
}
}
</script>
</head> <body>
<input type="text" id="txtStrDate" value="1989haha" />
<input type="button" value="check date" onclick="checkDate();" /> </body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
</head> <body>
<script type="text/javascript"> function checkDate()
{
var strDate = document.getElementById("txtStrDate").value;
var result=strDate.match(/^1[8-9]\d{2}/);
if(result==null)
{
alert("请输入正确的日期格式!,例如:2009-01-01。\r\n 或从时间列表中选择日期。");
}
else
{
alert("符合您的要求");
}
}
</script> <input id="txtStrDate" type="text" value="123" /><input id="btn" type="button" value="验证" onclick="checkDate() " />
</body>
</html>