本文介绍了在PHP中简单验证,但它不打电话,请帮助我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<html>
<head>
<script>
	function validateForm()
	{
		var x = document.forms["myform"]["txtname"].value;
		if (x == null || x=="") {
			aleart ("please enter the name");
			return false;
		}
	}
</script>
</head>
<body>
	<form name="myform" action="demo.php">
		Name
		<input type ="text" name= "txtname"><br />
		<input type="submit" value ="Submit">
	</form>

</body>
</html>

推荐答案

alert 

不是

aleart



接下来,你还没有调用validateForm()函数


Next, you have not called the validateForm() function at all

<form name="myform" action="#" onSubmit="return validateForm();">  


<html>
<head>
<script>
	function validateForm()
	{
		var x = document.forms["myform"]["txtname"].value;
		if (x == null || x=="") {
			alert ("please enter the name");
			return false;
		}
	}
</script>
</head>
<body>
	<form name="myform" action="demo.php" onSubmit="return validateForm();">
		Name
		<input type ="text" name= "txtname"><br />
		<input type="submit" value ="Submit">
	</form>
 
</body>
</html>



这篇关于在PHP中简单验证,但它不打电话,请帮助我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 00:20