zoneminder/web/skins/classic/views/js/user.js

34 lines
977 B
JavaScript
Raw Normal View History

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";
}
2017-05-19 01:50:56 +08:00
} else if ( newUser ) {
errors[errors.length] = "You must supply a password";
}
if ( errors.length ) {
alert(errors.join("\n"));
2020-07-31 00:15:05 +08:00
return false;
2017-05-19 01:50:56 +08:00
}
return true;
}
function initPage() {
$j('#contentForm').submit(function(event) {
if ( validateForm(this) ) {
$j('#contentButtons').hide();
return true;
} else {
return false;
};
});
} // end function initPage
window.addEventListener('DOMContentLoaded', initPage);