← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11369: Add validation for program fields when to define custion registration form for a program.

 

------------------------------------------------------------
revno: 11369
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-07-09 13:45:49 +0700
message:
  Add validation for program fields when to define custion registration form for a program.
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewPatientRegistationForm.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewPatientRegistationForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewPatientRegistationForm.js	2013-07-09 06:32:58 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewPatientRegistationForm.js	2013-07-09 06:45:49 +0000
@@ -189,6 +189,7 @@
 
 function validateProgramFields()
 {
+	var requiredFields = {};
 	jQuery('#programAttrSelector option').each(function() {
 		var item = jQuery(this);
 		if( item.attr('mandatory')=='true'){
@@ -216,7 +217,26 @@
 		});
 	}
 	
-	return requiredFields;
+	var violate = "";
+	if( Object.keys(requiredFields).length > 0 )
+	{
+		violate = '<h3>' + i18n_please_insert_all_required_fields + '<h3>';
+		for (var idx in requiredFields){
+			violate += " - " + requiredFields[idx] + '<br>';
+		}
+		jQuery('#validateDiv').html(violate).dialog({
+			title:i18n_required_fields_valivation,
+			maximize:true, 
+			closable:true,
+			modal:false,
+			overlay:{background:'#000000', opacity:0.1},
+			width:500,
+			height:300
+		});
+		return false;
+	}
+	
+	return true;
 }
 
 function validateFormOnclick()
@@ -432,7 +452,7 @@
 		setHeaderDelayMessage( i18n_enter_a_name );
 		return false;
 	}
-	else
+	else if(validateProgramFields())
 	{
 		$.postUTF8( 'validateDataEntryForm.action',
 		{