2 function add_password_validation (fieldid,nologin) {
3 var inputfield = document.getElementById(fieldid);
4 inputfield.onchange = function () {
5 var fieldid = this.id+'_result';
6 var resultfield = document.getElementById(fieldid);
8 var svcfield = document.getElementById(this.id+'_svcnum');
10 svcnum = svcfield.options[svcfield.selectedIndex].value;
13 resultfield.innerHTML = '<SPAN STYLE="color: blue;">Validating password...</SPAN>';
16 check_password: this.value,
19 validate_data['svcnum'] = svcnum;
22 url: 'xmlrpc_validate_passwd.php',
25 success: function ( result ) {
26 result = JSON.parse(result);
27 var resultfield = document.getElementById(fieldid);
29 var errorimg = '<IMG SRC="images/error.png" style="width: 1em; display: inline-block; padding-right: .5em">';
30 var validimg = '<IMG SRC="images/tick.png" style="width: 1em; display: inline-block; padding-right: .5em">';
31 if (result.password_valid) {
32 resultfield.innerHTML = validimg+'<SPAN STYLE="color: green;">Password valid!</SPAN>';
33 } else if (result.password_invalid) {
34 resultfield.innerHTML = errorimg+'<SPAN STYLE="color: red;">'+result.password_invalid+'</SPAN>';
36 resultfield.innerHTML = '';
40 error: function ( jqXHR, textStatus, errorThrown ) {
41 var resultfield = document.getElementById(fieldid);
42 console.log('ajax error: '+textStatus+'+'+errorThrown);
44 resultfield.innerHTML = '';