jQuery events don't provide synchronization of input values ​​from other inputs during form submission
P粉276876663
P粉276876663 2023-08-01 11:38:57
0
1
455
<p><br /></p> <pre class="brush:php;toolbar:false;">$(document).ready(function () { $('#StaffNumber').on('keyup', function () { var staffNo = $(this).val(); $('#Username').val('EMP' staffNo); }); });</pre> <p>Here the username input is populated with a new value, but the value is not available when the form is submitted. Additionally, I need a field validation on the username that fires on submit even after the value is populated in a jQuery event. How to preserve the value of username?</p> <p><code>$('#StaffNumber').on('input', function () {...}); </code></p> <p><code>$('#StaffNumber').on('keyup paste', function () {...});</code></p> <p>I also tried the above activities, but still no value retained!</p>
P粉276876663
P粉276876663

reply all(1)
P粉394812277

Make sure the event binding code is in $(document).ready(). Use change event instead of keyup for #StaffNumber input field. Combine the two keyup and change events if necessary. Check custom form submission handling and prevent default form submission behavior. Validate the form validation code to identify the updated value of Username.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template