保持提交按钮被禁用,直到表单完成并确认密码 [英] Keep submit button disabled until form is complete and confirming password

查看:154
本文介绍了保持提交按钮被禁用,直到表单完成并确认密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有很多关于这方面的文章,但无论我尝试什么,我的表单都没有任何作用。



我只希望直到所有字段都填写为止,提交按钮才会被禁用,并且我希望 $ mypassword 已选中在提交之前等于 $ myconfirmpassword



如果你能找到有用的东西。非常感谢你!

显然,有些东西是隐藏在隐私之中的,因为你看不到我的CSS和PHP信息。

 < div id =containerstyle =height:700px;> 
< a href =login.phpclass =anchor>< div id =back>
< h2>返回< / h2>
< / div>< / a>
< div id =registration_container>
< tr>
< form name =form3method =postaction =check_finish_registration.php>
< td>
< tr>
< td colspan =3>< strong>完成注册< / strong>< / td>
< / tr>
< tr>
< td width =2000>名字< / td>
< td width =6>:< / td>
< td width =294><?php echo $ fname?>< / td>
< / tr>
< tr>
< td width =2000>中间名*< / td>
< td width =6>:< / td>
< td width =294>< input type =textname =mymnameid =mymname>< / td>
< / tr>
< tr>
< td width =2000>姓氏< / td>
< td width =6>:< / td>
< td width =294><?php echo $ lname?>< / td>
< / tr>
< tr>
< td width =2000>建立使用者名称< / td>
< td width =6>:< / td>
< td width =294>< input type =textname =myusernameid =myusername>< / td>
< / tr>
< tr>
< td width =2000>建立密码*< / td>
< td width =6>:< / td>
< td width =294>< input type =textname =mypasswordid =mypassword>< / td>
< / tr>
< tr>
< td width =2000>确认您的密码*< / td>
< td width =6>:< / td>
< td width =294>< input type =textname =myconfirmpasswordid =myconfirmpassword>< / td>
< / tr>
< tr>
< td width =2000>输入您的Sigma编号*< / td>
< td width =6>:< / td>
< td width =294>< input type =textname =mysnumberid =mysnumber>< / td>
< / tr>
< tr>
< td width =2000>电子邮件地址*< / td>
< td width =6>:< / td>
< td width =294>< input type =textname =myemailid =myemail>< / td>
< / tr>
< tr>


< td width =2000> *必填字段< / td>
< td>& nbsp;< / td>
< td>< input type =submitid ='register'value =Registerdisabled ='disabled'>< / td>
< / tr>
< / table>
< / td>
< / form>

< / tr>
< / table>
< / div>
< / div>


解决方案

为什么不禁用提交按钮你只是尝试验证表单,以便直到用户输入正确的值,表单才会被提交到数据库?关于密码和确认密码字段验证

 < script type =text / javascript> 
函数passwordConfirm(){
var confirmPass = document.getElementById(confirmpassid)。value
if(pass!= confirmPass){
alert(密码不匹配);
}
}


I know that there are a bunch of posts about this already, but no matter what I try, nothing works for my form.

I simply want the submit button to be disabled until all fields are filled in, and I want $mypassword checked to equal $myconfirmpassword before submitting.

If you can find something that works. THANK YOU SO MUCH!!

Obviously, some things are hidden for privacy purposes, as you can't see my CSS and PHP info.

<div id="container" style="height:700px;">
<a href="login.php" class="anchor"><div id="back">
 <h2>Back</h2>             
 </div></a>
    <div id="registration_container" >
   <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#FF9">
    <tr>
<form name="form3" method="post" action="check_finish_registration.php">
        <td>
        <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FF9">
            <tr>
                <td colspan="3"><strong>Complete Registration </strong></td>
            </tr>
            <tr>
                <td width="2000">First Name</td>
                <td width="6">:</td>
                <td width="294"><?php echo $fname ?></td>
            </tr>
            <tr>
                <td width="2000">Middle Name*</td>
                <td width="6">:</td>
                <td width="294"><input type="text" name="mymname" id="mymname"></td>
            </tr>
            <tr>
                <td width="2000">Last Name</td>
                <td width="6">:</td>
                <td width="294"><?php echo $lname ?></td>
            </tr>
             <tr>
                <td width="2000">Create a Username*</td>
                <td width="6">:</td>
                <td width="294"><input type="text" name="myusername" id="myusername"></td>
            </tr>
             <tr>
                <td width="2000">Create a Password*</td>
                <td width="6">:</td>
                <td width="294"><input type="text" name="mypassword" id="mypassword"></td>
            </tr>
             <tr>
                <td width="2000">Confirm Your Password*</td>
                <td width="6">:</td>
                <td width="294"><input type="text" name="myconfirmpassword" id="myconfirmpassword"></td>
            </tr>
             <tr>
                <td width="2000">Enter your Sigma Number*</td>
                <td width="6">:</td>
                <td width="294"><input type="text" name="mysnumber" id="mysnumber"></td>
            </tr>
             <tr>
                <td width="2000">E-Mail Address*</td>
                <td width="6">:</td>
                <td width="294"><input type="text" name="myemail" id="myemail"></td>
            </tr>
            <tr>


                <td width="2000">* required field</td>
                <td>&nbsp;</td>
                <td><input   type="submit" id='register' value="Register"disabled='disabled'></td>
            </tr>
        </table>
        </td>
</form>

     </tr>
    </table>
    </div>    
</div>

解决方案

Instead of disabling the submit button, why don't you just try to validate the form so that until the user enters the correct values, the form will not be submitted to the database? And about the password and confirm password fields validation

   <script type="text/javascript">
    function passwordConfirm() {
        var confirmPass = document.getElementById("confirmpassid").value
        if(pass != confirmPass) {
            alert("Mismatching passwords");
        }
      }

这篇关于保持提交按钮被禁用,直到表单完成并确认密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆