Bug 11002: simplify patron mandatory field validation

When the pref BorrowerMandatoryField is set and a librarian forget to
fill fields, a js popup appears with the following message:
  "The following fields are mandatory: surname, etc."
The fields are not translatable.

Test plan:
- fill the pref BorrowerMandatoryField with something like:
  title|zipcode|surname|cardnumber|branchcode
- go the members/memberentry.pl?op=add page
- verify you are not allowed to add the patron without filling all
  mandatory fields.

Signed-off-by: Paola Rossi <paola.rossi@cineca.it>
Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
Jonathan Druart 2013-10-07 10:41:24 +02:00 committed by Galen Charlton
parent f66f34a420
commit c900a47aa8
2 changed files with 5 additions and 34 deletions

View file

@ -98,38 +98,6 @@ function check_form_borrowers(nav){
}
}
if (document.form.BorrowerMandatoryField.value==='')
{}
else
{
var champ_verif = document.form.BorrowerMandatoryField.value.split ('|');
message += MSG_MISSING_MANDATORY;
message += "\n";
for (var i=0; i<champ_verif.length; i++) {
if (document.getElementsByName(""+champ_verif[i]+"")[0]) {
var val_champ=eval("document.form."+champ_verif[i]+".value");
var ref_champ=eval("document.form."+champ_verif[i]);
//check if it's a select
if (ref_champ.type=='select-one'){
// check to see if first option is selected and is blank
if (ref_champ.options[0].selected &&
ref_champ.options[0].text === ''){
// action if field is empty
message_champ+=champ_verif[i]+"\n";
//test to know if you must show a message with error
statut=1;
}
} else {
if ( val_champ === '' ) {
// action if the field is not empty
message_champ+=champ_verif[i]+"\n";
statut=1;
}
}
}
}
}
if ( document.form.password.value != document.form.password2.value ){
if ( message_champ !== '' ){
message_champ += "\n";
@ -182,4 +150,8 @@ $(document).ready(function(){
$("#debarreduntil").hide();
}
});
var mandatory_fields = $("input[name='BorrowerMandatoryField']").val().split ('|');
$(mandatory_fields).each(function(){
$("[name='"+this+"']").attr('required', 'required');
});
});

View file

@ -83,7 +83,6 @@
var MSG_DUPLICATE_PATRON = _("Warning: Duplicate patron");
var MSG_DUPLICATE_ORGANIZATION = _("Warning: Duplicate organization");
var MSG_LATE_EXPIRY = _("Warning: Expiration date falls before enrollment date");
var MSG_MISSING_MANDATORY = _("The following fields are mandatory:");
var MSG_DUPLICATE_SUSPICION = _("Please confirm whether this is a duplicate patron");
var MSG_PASSWORD_MISMATCH = _("The passwords entered do not match");
//]]>