1 <script language="JavaScript" type="text/javascript">
3 function CheckDate(field) {
6 // this function checks id date is like JJ/MM/AAAA
7 var amin = 1900; // ann�e mini
8 var amax = 2100; // ann�e maxi
10 var date = d.split("/");
15 if ( (date.length < 2) && (ok==1) ) {
16 msg = _("Separator must be /");
17 alert(msg); ok=0; field.focus();
26 if ( ((isNaN(dd))||(dd<1)||(dd>31)) && (ok==1) ) {
27 msg = _("day not correct.");
28 alert(msg); ok=0; field.focus();
33 if ( ((isNaN(mm))||(mm<1)||(mm>12)) && (ok==1) ) {
34 msg = _("month not correct.");
35 alert(msg); ok=0; field.focus();
40 if ( ((isNaN(yyyy))||(yyyy<amin)||(yyyy>amax)) && (ok==1) ) {
41 msg = _("years not correct.");
42 alert(msg); ok=0; field.focus();
48 //function test if member is unique and if it's right the member is registred
52 if ( document.form.check_member.value==1){
53 if (document.form.categorycode.value != "I"){
55 msg1 += ("Warning !!!! Duplicate borrower!!!!");
57 check_form_borrowers(0);
58 document.form.submit();
61 msg2 += ("Warning !!!! Duplicate organisation!!!!");
63 check_form_borrowers(0);
68 document.form.submit();
73 //function test if date enrooled < date expiry
74 function check_manip_date(status) {
75 if (status=='verify'){
76 // this part of function('verify') is used to check if dateenrolled<date expiry
77 if (document.form.dateenrolled != '' && document.form.dateexpiry.value !='') {
78 var myDate1=document.form.dateenrolled.value.split ('/');
79 var myDate2=document.form.dateexpiry.value.split ('/');
80 if ((myDate1[2]>myDate2[2])||(myDate1[2]==myDate2[2] && myDate1[1]>myDate2[1])||(myDate1[2]==myDate2[2] && myDate1[1]>=myDate2[1] && myDate1[0]>=myDate2[0]))
83 document.form.dateenrolled.focus();
84 var msg = ("Warning !!! check date expiry >= date enrolment");
93 // function to test all fields in forms and nav in different forms(1 ,2 or 3)
94 function check_form_borrowers(nav){
96 if (nav < document.form.step.value) {
97 document.form.step.value=nav;
98 if ((document.form.step.value==0) && document.form.check_member.value == 1 )
101 if (document.form_double.answernodouble) {
102 if( (!(document.form_double.answernodouble.checked))){
103 document.form.nodouble.value=0;
106 document.form.nodouble.value=1;
110 document.form.submit();
113 if (document.form.BorrowerMandatoryField.value==''||document.form.FormFieldList.value=='' )
117 var champ_verif = document.form.BorrowerMandatoryField.value.split ('|');
118 var champ_form= document.form.FormFieldList.value.split('|');
119 var message ="The following fields are mandatory :\n";
120 var message_champ="";
121 for (var j=0; j<champ_form.length; j++){
122 if (document.getElementsByName(""+champ_form[j]+"")[0]){
123 for (var i=0; i<champ_verif.length; i++) {
124 if (document.getElementsByName(""+champ_verif[i]+"")[0]) {
125 var val_champ=eval("document.form."+champ_verif[i]+".value");
126 var ref_champ=eval("document.form."+champ_verif[i]);
127 var val_form=eval("document.form."+champ_form[j]+".value");
128 if (champ_verif[i] == champ_form[j]){
129 //check if it's a select
130 if (ref_champ.type=='select-one'){
131 if (ref_champ.options[0].selected ){
132 // action if field is empty
133 message_champ+=champ_verif[i]+"\n";
134 //test to konw if you must show a message with error
138 if ( val_champ == '' ) {
139 // action if the field is not empty
140 message_champ+=champ_verif[i]+"\n";
150 //borrowers form 2 test if u chcked no to the quetsion of double
151 if (document.form.step.value==2 && statut!=1 && document.form.check_member.value > 0 )
155 if (!(document.form_double.answernodouble.checked)){
158 message_champ+=("Please confirm suspicious duplicate borrower !!! ");
160 document.form.nodouble.value=0;
163 document.form.nodouble.value=1;
168 //alert if at least 1 error
169 alert(message+"\n"+message_champ);
173 document.form.step=nav;
174 document.form.submit();
179 function Dopop(link) {
180 // // var searchstring=document.form.value[i].value;
181 var newin=window.open(link,'popup','width=600,height=400,resizable=no,toolbar=false,scrollbars=no,top');
184 function Dopopguarantor(link) {
186 var newin=window.open(link,'popup','width=600,height=400,resizable=no,toolbar=false,scrollbars=yes,top');