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";
|
|
|
|
}
|
|
|
|
var monitorIds = new Array();
|
|
|
|
for ( var i = 0; i < form.elements['monitorIds'].options.length; i++ ) {
|
2019-01-19 23:32:40 +08:00
|
|
|
if ( form.elements['monitorIds'].options[i].selected ) {
|
2017-05-19 01:50:56 +08:00
|
|
|
monitorIds[monitorIds.length] = form.elements['monitorIds'].options[i].value;
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2017-05-19 01:50:56 +08:00
|
|
|
}
|
|
|
|
form.elements['newUser[MonitorIds]'].value = monitorIds.join( ',' );
|
|
|
|
if ( errors.length ) {
|
|
|
|
alert( errors.join( "\n" ) );
|
2019-01-19 23:32:40 +08:00
|
|
|
return ( false );
|
2017-05-19 01:50:56 +08:00
|
|
|
}
|
2019-01-19 23:32:40 +08:00
|
|
|
return ( true );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|