dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19122
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8217: Add default validation for phone number of person.
------------------------------------------------------------
revno: 8217
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-09-24 13:21:49 +0700
message:
Add default validation for phone number of person.
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.validate.ext.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-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm 2012-09-23 09:30:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm 2012-09-24 06:21:49 +0000
@@ -60,7 +60,7 @@
<tr>
<td class='text-column'><label for="phoneNumber">$i18n.getString( "phone_number" )</label></td>
<td class="input-column">
- <input type="text" id="phoneNumber" name="phoneNumber" value="$!patient.phoneNumber" />
+ <input type="text" id="phoneNumber" name="phoneNumber" value="$!patient.phoneNumber" class="{validate:{phone:true}}"/>
</td>
</tr>
=== 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-03-12 13:38:39 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.validate.ext.js 2012-09-24 06:21:49 +0000
@@ -292,6 +292,11 @@
|| /^([01][0-9])|(2[0123]):([0-5])([0-9])$/.test(value);
}, "Please enter a valid time, between 00:00 and 23:59");
+
+jQuery.validator.addMethod("phone", function(value, element) {
+ return this.optional(element) || (/^(\+)\d+$/.test(value));
+}, "Please enter valid phone number");
+
// TODO check if value starts with <, otherwise don't try stripping anything
jQuery.validator.addMethod("strippedminlength",
function(value, element, param) {