4.7
作者:互联网
function validateForm() { var x=document.forms["myForm"]["fname"].value; if (x==null || x=="") { alert("姓必须填写"); return false; } }
实例:
<form name="myForm" action="demo-form.php" onsubmit="return validateForm()" method="post"> 姓: <input type="text" name="fname"> <input type="submit" value="提交"> </form>
标签:function,4.7,return,validateForm,myForm,null 来源: https://www.cnblogs.com/gj-zzh2021/p/16120163.html