← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8765: Add time-validation for time field in Schedule Message form.

 

------------------------------------------------------------
revno: 8765
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-10-30 15:12:59 +0700
message:
  Add time-validation for time field in Schedule Message form.
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.validate.ext.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/scheduleSendMessage.vm


--
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-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.validate.ext.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.validate.ext.js	2012-10-22 16:02:20 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.validate.ext.js	2012-10-30 08:12:59 +0000
@@ -128,6 +128,7 @@
     return this.optional(element) || /^[a-z-.,()'\"\s]+$/i.test(value);
 }, "Letters or punctuation only please");
 
+
 jQuery.validator.addMethod("alphanumericwithbasicpuncspaces", function(value,
     element) {
     //return this.optional(element) || /^[\w-.,()\/'\"\s]+$/i.test(value);
@@ -289,7 +290,7 @@
 
 jQuery.validator.addMethod("time", function(value, element) {
     return this.optional(element)
-    || /^([01][0-9])|(2[0123]):([0-5])([0-9])$/.test(value);
+    || /^(([0-1]?[0-9])|([2][0-3])):([0-5]?[0-9])(:([0-5]?[0-9]))?$/i.test(value);
 }, "Please enter a valid time, between 00:00 and 23:59");
 
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2012-10-30 06:12:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2012-10-30 08:12:59 +0000
@@ -313,4 +313,5 @@
 add_multi_rule = Add multi rule
 no_aggregation = No aggregation
 age_at_visit_days_since_birth = Age at visit (days since birth)
-formula = Formula
\ No newline at end of file
+formula = Formula
+schedule_message_form = Schedule message
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/scheduleSendMessage.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/scheduleSendMessage.vm	2012-10-30 06:12:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/scheduleSendMessage.vm	2012-10-30 08:12:59 +0000
@@ -1,33 +1,46 @@
-<h3>$i18n.getString('schedule_message') #openHelp( "schedule_sending_message" )</h3>
-<table>
-	<tbody>
-		<tr>
-			<td>$i18n.getString( "time_for_sending_message" )</td>
-			<td>
-				<input type="text" id="timeSendingMessage" name="timeSendingMessage" value="$!timeSendingMessage" style="width:295px;"/>
-			</td>
-		</tr>
-		
-		<tr>
-			<td></td>
-			<td>
-				<input type="button" style="width:150px;" id="scheduledBtn" name="scheduledBtn"
-				#if ( $running=='true' )
-					value="$i18n.getString( 'stop' )"
-				#else
-					value="$i18n.getString( 'start' )"
-				#end
-				onclick="scheduleTasks();"/>
-				<input type="button" id="executeButton" name="executeButton" style="width:150px;" value="$i18n.getString( 'execute' )" onclick="executeTasks();" #if ( $running=='false' ) disabled #end/>
-			</td>
-		</tr>
-		
-	</tbody>
-</table>
-<span id="info">$i18n.getString( "scheduling_is" ) $!i18n.getString( $!status )</span>
-<span id='message'></span>
+<h3>$i18n.getString('schedule_message_form') #openHelp( "schedule_sending_message" )</h3>
+<form id='scheduleMessageForm' name='scheduleMessageForm' method="post">
+	<table>
+		<tbody>
+			<tr>
+				<td>$i18n.getString( "time_for_sending_message" )</td>
+				<td>
+					<input type="text" id="timeSendingMessage" name="timeSendingMessage" value="$!timeSendingMessage" style="width:295px;" class="{validate:{required:true,time:true}}"/>
+				</td>
+			</tr>
+			
+			<tr>
+				<td></td>
+				<td>
+					<input type="submit" style="width:150px;" id="scheduledBtn" name="scheduledBtn"
+					#if ( $running=='true' )
+						value="$i18n.getString( 'stop' )"
+					#else
+						value="$i18n.getString( 'start' )"
+					#end
+					onclick="javascript:isExecute=false;"/>
+					<input type="submit" id="executeButton" name="executeButton" style="width:150px;" value="$i18n.getString( 'execute' )" onclick="javascript:isExecute=true;" #if ( $running=='false' ) disabled #end/>
+				</td>
+			</tr>
+			
+		</tbody>
+	</table>
+	<span id="info">$i18n.getString( "scheduling_is" ) $!i18n.getString( $!status )</span>
+	<span id='message'></span>
+</form>
 
 <script>
+	jQuery(document).ready(	function(){
+		validation( 'scheduleMessageForm', function(form){
+			if(isExecute){
+				executeTasks();
+			}
+			else{
+				scheduleTasks();
+			}
+		});
+	});
+	
 	var i18n_scheduled = '$encoder.jsEscape( $i18n.getString( "run_success" ) , "'" )';
 	var i18n_start = '$encoder.jsEscape( $i18n.getString( "start" ) , "'" )';
 	var i18n_stop = '$encoder.jsEscape( $i18n.getString( "stop" ) , "'" )';