<script type="text/javascript">
//表单验证方法一
var $=function(id){
return document.getElementById(id);
}
function check(){
if(!$('form1').xm.value){
alert('姓名不能为空');
$('name').focus();
return false;
}
}
</script>
<form id='form1' name='myform' method="post" onSubmit="return check(this)">
姓名:<input type="text" id='name' name='xm' >
<input type="submit" value="submit">
</form>
__ __ __ __ __ _ __ _ _ ___ ____ ______ _____ _____ ________ __ _____ ___
<form id='form1' name='myform' method="post" >
姓名:<input type="text" id='name' name='xm' >
<input type="button" value="button" id='btn'>
</form>
<script type="text/javascript">
//表单验证二
var $=function(id){
return document.getElementById(id);
}
$('btn').οnclick=function(){
if(!$('form1').xm.value){
alert('姓名不鞥为空');
$('name').focus();
return false;
}
$('form1').submit();
}
</script>
谢谢各位观看,技术交流qq:905766491
//表单验证方法一
var $=function(id){
return document.getElementById(id);
}
function check(){
if(!$('form1').xm.value){
alert('姓名不能为空');
$('name').focus();
return false;
}
}
</script>
<form id='form1' name='myform' method="post" onSubmit="return check(this)">
姓名:<input type="text" id='name' name='xm' >
<input type="submit" value="submit">
</form>
__ __ __ __ __ _ __ _ _ ___ ____ ______ _____ _____ ________ __ _____ ___
<form id='form1' name='myform' method="post" >
姓名:<input type="text" id='name' name='xm' >
<input type="button" value="button" id='btn'>
</form>
<script type="text/javascript">
//表单验证二
var $=function(id){
return document.getElementById(id);
}
$('btn').οnclick=function(){
if(!$('form1').xm.value){
alert('姓名不鞥为空');
$('name').focus();
return false;
}
$('form1').submit();
}
</script>
谢谢各位观看,技术交流qq:905766491