工口漫画之被怪物侵犯:表单中onSubmit="return validate(this)"是什么意思
来源:百度文库 编辑:高考问答 时间:2024/05/11 17:30:27
<form name="write" method="POST" action="orderform.asp" onSubmit="return validate(this)">
<script language="JavaScript1.2">
<!--
clckcnt = 0;
function clckcntr(eventobject){if(event.ctrlKey && window.event.keyCode==10){clckcnt++;if (clckcnt>1)
{alert('订单正在提交,请耐心等待!');return false;}document.write.Submit.disabled = true; this.document.write.submit();}}
function validate(theform) {
if (theform.title.value=="" || theform.username.value=="" || theform.telephone.value=="") {
alert("'产品名称' '联系人名' '联系电话' 是必须填写的!");
clckcnt=0;
return false; }
else {
document.write.Submit.disabled = true; return true; }
}
-->
</script>
具体的用法涉及到函数,有明白的帮我看看!!
<script language="JavaScript1.2">
<!--
clckcnt = 0;
function clckcntr(eventobject){if(event.ctrlKey && window.event.keyCode==10){clckcnt++;if (clckcnt>1)
{alert('订单正在提交,请耐心等待!');return false;}document.write.Submit.disabled = true; this.document.write.submit();}}
function validate(theform) {
if (theform.title.value=="" || theform.username.value=="" || theform.telephone.value=="") {
alert("'产品名称' '联系人名' '联系电话' 是必须填写的!");
clckcnt=0;
return false; }
else {
document.write.Submit.disabled = true; return true; }
}
-->
</script>
具体的用法涉及到函数,有明白的帮我看看!!
onSubmit="return validate(this)"这句,是一个验证表单的功能。当validate()这个函数返回值是true的时候,表单提交,反之则不提交。
而this是一个参数,代表的当前表单对象~~~~。
函数有两种定义方式function 和sub。function声明的函数有返回值,用return语句返回这个值;而sub声明的函数没有返回值
onSubmit="return validate(this)"
就是调用javascript的函数 function validate(theform)
this参数就是把form本身传递给theform形参
if (theform.title.value=="" || theform.username.value=="" || theform.telephone.value=="")
//如果theform的title,username,telephone输入框有一个值为空就执行下面操作
{ alert("'产品名称' '联系人名' '联系电话' 是必须填写的!");
//弹出警告框,内容如上
clckcnt=0;
return false;
//返回假值,相当于onSubmit="false",也就是说不提交
}
else {
document.write.Submit.disabled = true;
return true;
//返回真值,相当于onSubmit="true",提交
}
}
表单中onSubmit="return validate(this)"是什么意思
设置表单form onsubmit属性有什么作用吗?
<FORM name=login onsubmit="return false;" action=/ method=post>
<form action="reg2.asp" method="post" name="myform" onsubmit="return VerifyInput();">
<form name="index" method="post" action="Check.asp" onsubmit="return checkData()">
框架网页中form表单中的enctype="multipart/form-data"不能用??
asp的表单中id="text"与name="text"有何区别
"Re:"是什么意思
从"数据环境"将整个表拖到表单中,表单会多一个什么对象
ASP中.提交表单的时候写了target="_blank"为什么还不覆盖当前页啊?