LP#1361266 Patron self-registration form accepts date of birth in wrong format
authorMichael Peters <mpeters@emeralddata.net>
Thu, 4 Dec 2014 20:56:53 +0000 (15:56 -0500)
committerChris Sharp <csharp@georgialibraries.org>
Mon, 5 Jan 2015 20:34:12 +0000 (15:34 -0500)
This patch applys some basic javascript to validate that a date entered is
at least in ISO 8601 format.  This prevents someone from entering "cupcake"
or 55/66/6666 as a valid date of birth by validating the stgu.dob input
at the time of submission.

Signed-off-by: Michael Peters <mpeters@emeralddata.net>
Open-ILS/src/templates/opac/register.tt2

index db7483b..4c3aead 100644 (file)
@@ -42,7 +42,7 @@ register_fields = [
 # The dojo date widget in the patron edit UI only accepts default 
 # values in ISO8601 format.  It will not accept locale-shaped dates.
 IF !ctx.register.settings.stgu.dob.example;
-    ctx.register.settings.stgu.dob.example = l('YYYY-MM-DD');
+    ctx.register.settings.stgu.dob.example = l('YYYY-MM-DD or YYYY/MM/DD');
 END;
 
 %]
@@ -95,7 +95,7 @@ END;
                 ) | html %]</h4>
         [% END %]
 
-        <form method='POST'>
+        <form method='POST' onSubmit="return dobValidate(document.getElementById('stgu.dob'))">
             <table>
                 <tr>
                     <td>
@@ -143,7 +143,8 @@ FOR field_def IN register_fields;
     </td>
     <td>
         <input 
-            type='text' 
+            type='text'
+            id='[% field_path %]'
             name='[% field_path %]'
             value='[% value || CGI.param(field_path) | html %]'/>
         [% IF require %]