File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6767</ div >
6868
6969< script >
70- // JavaScript to validate password match
71- document . getElementById ( 'confirm_password' ) . addEventListener ( 'input' , function ( ) {
72- const password = document . getElementById ( 'password' ) . value ;
73- const confirmPassword = this . value ;
74- if ( password !== confirmPassword ) {
75- this . setCustomValidity ( 'Passwords do not match.' ) ;
76- } else {
77- this . setCustomValidity ( '' ) ;
70+ ( function ( ) {
71+ const password = document . getElementById ( 'password' ) ;
72+ const confirmPassword = document . getElementById ( 'confirm_password' ) ;
73+
74+ function syncConfirmPasswordValidity ( ) {
75+ if ( password . value !== confirmPassword . value ) {
76+ confirmPassword . setCustomValidity ( 'Passwords do not match.' ) ;
77+ } else {
78+ confirmPassword . setCustomValidity ( '' ) ;
79+ }
7880 }
79- } ) ;
81+
82+ password . addEventListener ( 'input' , syncConfirmPasswordValidity ) ;
83+ confirmPassword . addEventListener ( 'input' , syncConfirmPasswordValidity ) ;
84+ } ) ( ) ;
8085</ script >
8186{% endblock %}
Original file line number Diff line number Diff line change 4848</ div >
4949
5050< script >
51- // JavaScript to validate password match
52- document . getElementById ( 'confirm_password' ) . addEventListener ( 'input' , function ( ) {
53- const newPassword = document . getElementById ( 'password' ) . value ;
54- const confirmNewPassword = this . value ;
55- if ( newPassword !== confirmNewPassword ) {
56- this . setCustomValidity ( 'Passwords do not match.' ) ;
57- } else {
58- this . setCustomValidity ( '' ) ;
51+ ( function ( ) {
52+ const password = document . getElementById ( 'password' ) ;
53+ const confirmPassword = document . getElementById ( 'confirm_password' ) ;
54+
55+ function syncConfirmPasswordValidity ( ) {
56+ if ( password . value !== confirmPassword . value ) {
57+ confirmPassword . setCustomValidity ( 'Passwords do not match.' ) ;
58+ } else {
59+ confirmPassword . setCustomValidity ( '' ) ;
60+ }
5961 }
60- } ) ;
62+
63+ password . addEventListener ( 'input' , syncConfirmPasswordValidity ) ;
64+ confirmPassword . addEventListener ( 'input' , syncConfirmPasswordValidity ) ;
65+ } ) ( ) ;
6166</ script >
6267{% endblock %}
You can’t perform that action at this time.
0 commit comments