ITeye博客

html : 表单提交前检查填入数据

belldeep · 2018-10-27 22:21 · javascript · html · Web前端 · Markdown

fund1.html


<!DOCTYPE html>
<html>
<head>
  <meta charset="GBK">
  <title>基金数据 </title>
<script type="text/javascript">
function check(form){
  if (navigator.appName == "Microsoft Internet Explorer"){
    if (navigator.appVersion.match(/MSIE [6789]\.0/i)){ 
      alert("IE 不支持此功能,需要能支持HTML5 的浏览器.");
      return false;
    }
  } 
  var fcode = form.f.value;
  if (fcode.length !=6 || isNaN(fcode)==true){
    alert("基金代码为6位数字"); form.f.focus(); 
    return false;
  }
  return true;
}
</script>
</head>
<body>
<p>
  <form name="form" action="fund1" method="get" target="show" onsubmit="return check(this)">
	<label>get </label><select id="a" name="a" >
	<option value="1" selected>基金净值</option>
	<option value="2">基金累计净值</option>
	</select>
	<label>基金代码:</label><input type="text" name="f" min="6" max="10" />
	<input type="submit" name="submit" value="提交->绘图" />
	<input type="button" name="button1" id="down1" value="数据下载" onClick="check1()" />
 </form>
</p>
  <iframe name="show" id="show" width="1000" height="600"/>   
</body>
</html>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。