- function check_form_borrowers(nav){
-var statut=0;
-if (nav < document.form.step.value) {
- document.form.step.value=nav;
- if ((document.form.step.value==0) && document.form.check_member.value == 1 )
- {
-
- if (document.form_double.answernodouble) {
- if( (!(document.form_double.answernodouble.checked))){
- document.form.nodouble.value=0;
- }
- else {
- document.form.nodouble.value=1;
- }
- }
- }
- document.form.submit();
-
-} else {
- if (document.form.BorrowerMandatoryField.value==''||document.form.FormFieldList.value=='' )
- {}
- else
- {
- var champ_verif = document.form.BorrowerMandatoryField.value.split ('|');
- var champ_form= document.form.FormFieldList.value.split('|');
- var message ="The following fields are mandatory :\n";
- var message_champ="";
- for (var j=0; j<champ_form.length; j++){
- if (document.getElementsByName(""+champ_form[j]+"")[0]){
- 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]);
- var val_form=eval("document.form."+champ_form[j]+".value");
- if (champ_verif[i] == champ_form[j]){
- //check if it's a select
- if (ref_champ.type=='select-one'){
- if (ref_champ.options[0].selected ){
- // action if field is empty
- message_champ+=champ_verif[i]+"\n";
- //test to konw 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;
- }
- }
- }
- }
- }
- }
- }
- }
-//borrowers form 2 test if u chcked no to the quetsion of double
- if (document.form.step.value==2 && statut!=1 && document.form.check_member.value > 0 )
- {
-
-
- if (!(document.form_double.answernodouble.checked)){
-
- message ="";
- message_champ+=("Please confirm suspicious duplicate borrower !!! ");
- statut=1;
- document.form.nodouble.value=0;
- }
- else {
- document.form.nodouble.value=1;
- }
- }
-
- if (statut==1){
- //alert if at least 1 error
- alert(message+"\n"+message_champ);
- }
- else
- {
- document.form.step=nav;
- document.form.submit();
- }
- }
+function check_form_borrowers(nav){
+ var statut=0;
+ var message = "";
+ var message_champ="";
+ if (document.form.check_member.value == 1 )
+ {
+ if (document.form_double.answernodouble) {
+ if( (!(document.form_double.answernodouble.checked))){
+ document.form.nodouble.value=0;
+ } else {
+ document.form.nodouble.value=1;
+ }
+ }
+ }
+
+ 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";
+ }
+ message_champ+= MSG_PASSWORD_MISMATCH;
+ statut=1;
+ }
+
+ //patrons form to test if you checked no to the question of double
+ if (statut!=1 && document.form.check_member.value > 0 ) {
+ if (!(document.form_double.answernodouble.checked)){
+ message_champ+= MSG_DUPLICATE_SUSPICION;
+ statut=1;
+ document.form.nodouble.value=0;
+ } else {
+ document.form.nodouble.value=1;
+ }
+ }
+
+ if (statut==1){
+ //alert if at least 1 error
+ alert(message+"\n"+message_champ);
+ return false;
+ } else {
+ document.form.submit();
+ }