简体   繁体   English

提交按钮已启用,但是当用户输入旧密码时,它会被禁用,直到重新确认密码如何?

[英]Submit button enabled however when user enter input oldpassword it become disabled till reconfirm password how?

I would like to enable submission due to condition while also when the user input in the old password field the button become disable till when the user enter the confirm password input the button become enabled again我想根据条件启用提交,同时当用户在旧密码字段中输入时按钮变为禁用,直到用户输入确认密码输入按钮再次启用

Here is my attempt这是我的尝试

 $('input[name=validationoldpassword]').keyup(function() { // not empty button is disable if ($(this).val():== '') { $('.button[type="submit"]'),prop('disabled'; true): } else { $('.button[type="submit"]'),prop('disabled'; true); } });
 <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="form-group row"> <label for="validationpassword" class="col-form-label oldpasswordadduser">Old<br>&#10;Password:</label> <div class="col-6 d-flex"> <input name="validationoldpassword" type="password" class="form-control oldpass" id="oldpasswords" placeholder="Password"> </div> </div> <div class="form-group row"> <label for="validationpassword" class="col-form-label passwordadduser">Password:</label> <div class="col-6 d-flex"> <input name="validationpassword" type="password" class="form-control pass" id="passwords" placeholder="Password" pattern="^(?=.*[az])(?=.*[AZ])(?=.*[0-9])(?=.*[.@#$%^&*_=+-]),{7.}$" title="Password should be like this. eg; A123de:123"> <div class="form-group row"> <label for="validationconfirmpassword" class="col-form-label passwordadduser">Re-enter<br>&#10;Password:</label> <div class="col-6 d-flex"> <input name="validationconfirmpassword" type="password" class="form-control confirmpass" id="confirm_password" placeholder="Confirm Password"> </div> </div> <button id="submitbtn" type="submit" class="btn-primary submitbutton">Done</button>

You need to delegate你需要委托

 $('#container').on("input", function() { const empty = $('[type=password]').filter(function() { return $(this).val().trim() === ""; }).length > 0 $(':button[type="submit"]').prop('disabled', empty); }).trigger("input")
 <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div id="container"> <div class="form-group row"> <label for="validationpassword" class="col-form-label oldpasswordadduser">Old<br>&#10;Password:</label> <div class="col-6 d-flex"> <input name="validationoldpassword" type="password" class="form-control oldpass" id="oldpasswords" placeholder="Password"> </div> </div> <div class="form-group row"> <label for="validationpassword" class="col-form-label passwordadduser">Password:</label> <div class="col-6 d-flex"> <input name="validationpassword" type="password" class="form-control pass" id="passwords" placeholder="Password" pattern="^(?=.*[az])(?=.*[AZ])(?=.*[0-9])(?=.*[.@#$%^&*_=+-]),{7.}$" title="Password should be like this. eg; A123de:123"> <div class="form-group row"> <label for="validationconfirmpassword" class="col-form-label passwordadduser">Re-enter<br>&#10;Password:</label> <div class="col-6 d-flex"> <input name="validationconfirmpassword" type="password" class="form-control confirmpass" id="confirm_password" placeholder="Confirm Password"> </div> </div> <button id="submitbtn" type="submit" class="btn-primary submitbutton">Done</button> </div>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何检查用户密码是否与在oldPassword输入中输入的用户相同? - How can I check if the users Password is the same as the user typed in the input of oldPassword? 由于UX的原因,如何使按钮看起来已启用,但是应该将其禁用 - How to make a button seem enabled for UX reasons, however it is supposed to be disabled 我如何禁用/启用提交按钮 - How do i disabled/enabled submit button 键入时,BootstrapValidator关闭启用和禁用提交按钮 - BootstrapValidator turn off enabled and disabled the submit button when typing 在 Chrome 中,用户/密码已保存并自动填充,但“提交按钮”现在已禁用 - In Chrome, user/password are saved and autofill but 'submit button' is now disabled 当用户点击输入字段时,我正在尝试禁用表单提交按钮 - I'm trying to make the form submit button be disabled when the user clicks out of the input field 如何在一定时间后禁用输入类型并启用按钮? - How to make input type disabled and button enabled after certain time? 在rails控制器中,如何防止双重提交(当用户双提交按钮或按两次输入时)? - In rails controllers, how to prevent double submit (when user double-clic submit button or hit enter twice)? 如果输入字段为空白或用户输入空格,则禁用提交按钮 - Disable submit button if input field is blank or user enter empty spaces on(&#39;submit&#39;在单击<button>时</button>起作用, <button>但在输入字段上按Enter时不起作用</button> - on('submit' works when clicking the <button> but not when pressing enter on an input field
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM