forked from wikimedia/mediawiki-extensions-NewSignupPage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNewSignupPage.js
32 lines (32 loc) · 1.03 KB
/
NewSignupPage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* JavaScript file for performing some interactive and client-side validation of
* the password fields on the registration form to avoid some user frustration,
* especially on mobile devices.
*
* @file
* @date 5 January 2016
* @author Jack Phoenix
*/
$( function() {
// Password match checker
$( 'input#wpPassword2, input#wpRetype' ).on( 'change', function() {
if ( $( 'span#password-match-check-result' ).length > 0 ) {
$( 'span#password-match-check-result' ).remove();
}
// If both the password and the "type password again" fields have
// content, but the contents do not match, complain to the user about it
if (
$( 'input#wpPassword2' ).val().length > 0 &&
$( 'input#wpRetype' ).val().length > 0 &&
!( $( 'input#wpPassword2' ).val() === $( 'input#wpRetype' ).val() )
)
{
var message = mw.msg( 'badretype' );
$( 'input#wpRetype' ).parent().append(
'<span id="password-match-check-result" class="error">' +
message + '</span>'
);
}
// @todo FIXME: whine if there is no password, maybe?
} );
} );