2017-05-19 01:50:56 +08:00
|
|
|
function validateForm( form, newUser ) {
|
|
|
|
var errors = new Array();
|
|
|
|
if ( !form.elements['newUser[Username]'].value ) {
|
|
|
|
errors[errors.length] = "You must supply a username";
|
|
|
|
}
|
|
|
|
if ( form.elements['newUser[Password]'].value ) {
|
|
|
|
if ( !form.conf_password.value ) {
|
|
|
|
errors[errors.length] = "You must confirm the password";
|
|
|
|
} else if ( form.elements['newUser[Password]'].value != form.conf_password.value ) {
|
|
|
|
errors[errors.length] = "The new and confirm passwords are different";
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
2017-05-19 01:50:56 +08:00
|
|
|
} else if ( newUser ) {
|
|
|
|
errors[errors.length] = "You must supply a password";
|
|
|
|
}
|
|
|
|
if ( errors.length ) {
|
2020-06-24 10:19:04 +08:00
|
|
|
alert(errors.join("\n"));
|
2020-07-09 09:53:12 +08:00
|
|
|
return false;
|
2017-05-19 01:50:56 +08:00
|
|
|
}
|
2020-06-24 10:19:04 +08:00
|
|
|
return true;
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
2020-06-24 10:19:04 +08:00
|
|
|
|
|
|
|
function initPage() {
|
|
|
|
$j('#contentForm').submit(function(event) {
|
|
|
|
if ( validateForm(this) ) {
|
|
|
|
$j('#contentButtons').hide();
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
});
|
2020-09-26 04:49:18 +08:00
|
|
|
|
|
|
|
// Manage the BACK button
|
|
|
|
document.getElementById("backBtn").addEventListener("click", function onBackClick(evt) {
|
|
|
|
evt.preventDefault();
|
|
|
|
window.history.back();
|
|
|
|
});
|
|
|
|
|
|
|
|
// Disable the back button if there is nothing to go back to
|
|
|
|
$j('#backBtn').prop('disabled', !document.referrer.length);
|
|
|
|
|
|
|
|
// Manage the REFRESH Button
|
|
|
|
document.getElementById("refreshBtn").addEventListener("click", function onRefreshClick(evt) {
|
|
|
|
evt.preventDefault();
|
|
|
|
window.location.reload(true);
|
|
|
|
});
|
2020-06-24 10:19:04 +08:00
|
|
|
} // end function initPage
|
|
|
|
|
|
|
|
window.addEventListener('DOMContentLoaded', initPage);
|