返回信息流就是一个注册的页面,在页面填写完相关的信息之后,要是必填的内容为空,就用JS弹出个对话框提示所填内容不能为空,然后就不往服务器端发送信息,只有要求的内容都填写完的时候才发送填写的注册信息。
有人知道咋搞不?
页面还不是PHP写的,用Perl写的cgi的页面,不过应该跟PHP调用的方式是一样的。
我把填写注册信息的那块贴出来。
<form id="confirm_account_form" method="post" action="token.cgi">
<input type="hidden" name="t" value="WYpct9EWno">
<input type="hidden" name="a" value="confirm_new_account">
<table>
<tr>
<th align="right">Email Address:</th>
<td>aabb@cd.com</td>
</tr>
<tr>
<th align="right"><small><i>(OPTIONAL)</i></small> <label for="realname">Real Name</label>:</th>
<td><input type="text" id="realname" name="realname" value=""></td>
</tr>
<tr>
<th align="right"><label for="passwd1">Type your password</label>:</th>
<td><input type="password" id="passwd1" name="passwd1" value=""></td>
</tr>
<tr>
<th align="right"><label for="passwd2">Confirm your password</label>:</th>
<td><input type="password" id="passwd2" name="passwd2" value=""></td>
</tr>
<tr>
<th align="right"><label for="grantor_name">Who gave you the access information of this site? Name</label>:</th>
<td><input type="text" id="grantor_name" name="grantor_name" value=""></td>
</tr>
<tr>
<th align="right"><label for="grantor_email">Email</label>:</th>
<td><input type="text" id="grantor_email" name="grantor_email" value=""></td>
</tr>
<tr>
<th align="right"><label for="access_reason">Why do you need to access to this bugzilla?</label></th>
<td><textarea name="access_reason", colus=40, rows=3></textarea></td>
</tr>
<tr>
<th align="right"> </th>
<td><input type="submit" id="confirm" value="Send"></td>
</tr>
</table>
</form>
这是一条镜像帖。来源:北邮人论坛 / www-technology / #11945同步于 2010/12/21
该镜像源已超过 30 天没有更新,可能在源站已被删除。
WWWTechnology机器人发帖
想用JS弹出个对话框
left
2010/12/21镜像同步9 回复
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
<td><input type="submit" id="confirm" value="Send"></td>
这里捕获onclick事件,检查完毕后再用js submit
【 在 zzcc 的大作中提到: 】
:
: <td><input type="submit" id="confirm" value="Send"></td>
: 这里捕获onclick事件,检查完毕后再用js submit
: ...................
能讲讲怎么具体实现么,我是不懂JavaScript...
【 在 left 的大作中提到: 】
: 能讲讲怎么具体实现么,我是不懂JavaScript...
<td><input type="button" id="confirm" value="Send" onclick="abc()"></td>
function abc()
{
if(document.getElementById('realname').value == "" )
alert("abc");
else if ( ............. )
alert("bca");
else
document.getElementById('confirm_account_form').submit();
}
form的onsubmit验证
<form id="confirm_account_form" method="post" action="token.cgi" onsubmit="return check();">
……
然后js里写check方法
function check(){
if(……){
alert("xx is null");
return false;
}else{
return true;
}
}
【 在 xxf 的大作中提到: 】
: form的onsubmit验证
: <form id="confirm_account_form" method="post" action="token.cgi" onsubmit="return check();">
: ……
: ...................
哦,这个专业多了
现在提示框是可以弹出来的,但是我要阻止住程序继续进行啊,不然框弹出来,还是可以继续注册,没起到效果啊。判断条件为空弹出对话框后怎么阻止程序继续进行啊?
程序现在是这样的
<form id="confirm_account_form" method="post" action="token.cgi">
<input type="hidden" name="t" value="[% token FILTER html %]">
<input type="hidden" name="a" value="confirm_new_account">
<table>
<tr>
<th align="right">Email Address:</th>
<td>[% email FILTER html %]</td>
</tr>
<tr>
<th align="right"><small><i>(OPTIONAL)</i></small> <label for="realname">Real Name</label>:</th>
<td><input type="text" id="realname" name="realname" value=""> *</td>
</tr>
<tr>
<th align="right"><label for="passwd1">Type your password</label>:</th>
<td><input type="password" id="passwd1" name="passwd1" value=""> *</td>
</tr>
<tr>
<th align="right"><label for="passwd2">Confirm your password</label>:</th>
<td><input type="password" id="passwd2" name="passwd2" value=""> *</td>
</tr>
<tr>
<th align="right"><label for="grantor_name">Who gave you the access information of this site? Name</label>:</th>
<td><input type="text" id="grantor_name" name="grantor_name" value=""> *</td>
</tr>
<tr>
<th align="right"><label for="grantor_email">Email</label>:</th>
<td><input type="text" id="grantor_email" name="grantor_email" value=""> *</td>
</tr>
<tr>
<th align="right"><label for="access_reason">Why do you need to access to this bugzilla?</label></th>
<td><textarea name="access_reason", colus=40, rows=3></textarea> *</td>
</tr>
<tr>
<th align="right"> </th>
<td><input type="submit" id="confirm" value="Send" onclick="checkinfo()"></td>
<script type="text/javascript">
function checkinfo()
{
if(document.getElementById('realname').value == "" )
{
alert("Please fill information marked with *");
return false;
}
else if (document.getElementById('passwd1').value == "")
{
alert("Please fill information marked with *");
return false;
}
else if (document.getElementById('passwd2').value == "")
{
alert("Please fill information marked with *");
return false;
}
else if (document.getElementById('grantor_name').value == "")
{
alert("Please fill information marked with *");
return false;
}
else if (document.getElementById('grantor_email').value == "")
{
alert("Please fill information marked with *");
return false;
}
else if (document.getElementById('access_reason').value == "")
{
alert("Please fill information marked with *");
return false;
}
else
document.getElementById('confirm_account_form').submit();
}
</script>
</tr>
</table>
</form>
【 在 left 的大作中提到: 】
: 现在提示框是可以弹出来的,但是我要阻止住程序继续进行啊,不然框弹出来,还是可以继续注册,没起到效果啊。判断条件为空弹出对话框后怎么阻止程序继续进行啊?
: 程序现在是这样的
: <form id="confirm_account_form" method="post" action="token.cgi">
: ...................
1、用4楼那个捕获onsubmit事件,如果不提交return false(我自学的时候没发现有这东西。。。)
2、把提交按钮改成type="button"
<form id="confirm_account_form" method="post" action="token.cgi" onsubmit="return checkinfo()">
<input type="hidden" name="t" value="[% token FILTER html %]">
<input type="hidden" name="a" value="confirm_new_account">
<table>
<tr>
<th align="right">Email Address:</th>
<td>[% email FILTER html %]</td>
</tr>
<tr>
<th align="right"><small><i>(OPTIONAL)</i></small> <label for="realname">Real Name</label>:</th>
<td><input type="text" id="realname" name="realname" value=""> *</td>
</tr>
<tr>
<th align="right"><label for="passwd1">Type your password</label>:</th>
<td><input type="password" id="passwd1" name="passwd1" value=""> *</td>
</tr>
<tr>
<th align="right"><label for="passwd2">Confirm your password</label>:</th>
<td><input type="password" id="passwd2" name="passwd2" value=""> *</td>
</tr>
<tr>
<th align="right"><label for="grantor_name">Who gave you the access information of this site? Name</label>:</th>
<td><input type="text" id="grantor_name" name="grantor_name" value=""> *</td>
</tr>
<tr>
<th align="right"><label for="grantor_email">Email</label>:</th>
<td><input type="text" id="grantor_email" name="grantor_email" value=""> *</td>
</tr>
<tr>
<th align="right"><label for="access_reason">Why do you need to access to this bugzilla?</label></th>
<td><textarea name="access_reason", colus=40, rows=3></textarea> *</td>
</tr>
<tr>
<th align="right"> </th>
<td><input type="submit" id="confirm" value="Send"></td>
<script type="text/javascript">
function checkinfo()
{
if(document.getElementById('realname').value == "" )
{
alert("Please fill information marked with *");
return false;
}
else if (document.getElementById('passwd1').value == "")
{
alert("Please fill information marked with *");
return false;
}
else if (document.getElementById('passwd2').value == "")
{
alert("Please fill information marked with *");
return false;
}
else if (document.getElementById('grantor_name').value == "")
{
alert("Please fill information marked with *");
return false;
}
else if (document.getElementById('grantor_email').value == "")
{
alert("Please fill information marked with *");
return false;
}
else if (document.getElementById('access_reason').value == "")
{
alert("Please fill information marked with *");
return false;
}
else
document.getElementById('confirm_account_form').submit();
}
</script>
</tr>
</table>
</form>
【 在 left 的大作中提到: 】
: 现在提示框是可以弹出来的,但是我要阻止住程序继续进行啊,不然框弹出来,还是可以继续注册,没起到效果啊。判断条件为空弹出对话框后怎么阻止程序继续进行啊?
: 程序现在是这样的
: <form id="confirm_account_form" method="post" action="token.cgi">
: ...................