[open-ils-commits] [GIT] Evergreen ILS branch master updated. 48b7fabf5991ca92f197444fc52524b59a76ed46

Evergreen Git git at git.evergreen-ils.org
Fri Sep 4 11:52:43 EDT 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  48b7fabf5991ca92f197444fc52524b59a76ed46 (commit)
      from  17082b62f2329f70d8128677d9bfaccb11896271 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 48b7fabf5991ca92f197444fc52524b59a76ed46
Author: Michael Peters <mpeters at emeralddata.net>
Date:   Thu Dec 4 15:56:53 2014 -0500

    LP#1361266 Patron self-registration form accepts date of birth in wrong format
    
    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 at emeralddata.net>
    Signed-off-by: Josh Stompro <stomproj at larl.org>
    Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>

diff --git a/Open-ILS/src/templates/opac/parts/js.tt2 b/Open-ILS/src/templates/opac/parts/js.tt2
index ed68480..f9600a5 100644
--- a/Open-ILS/src/templates/opac/parts/js.tt2
+++ b/Open-ILS/src/templates/opac/parts/js.tt2
@@ -1,6 +1,20 @@
 <!-- JS imports, etc.  -->
 <script type="text/javascript" src="[% ctx.media_prefix %]/js/ui/default/opac/simple.js"></script>
 
+<!-- DOB validation for Patron Registration in OPAC -->
+<script type="text/javascript">
+    function dobValidate(input) {
+        var validformat = /^(19|20)\d\d([- /.])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])$/
+        var returnval = false
+        if (!validformat.test(input.value))
+            alert("You have entered an invalid date, or an improperly formatted date.  Please enter Date of Birth in YYYY-MM-DD or YYYY/MM/DD format and try again.")
+        else
+            returnval = true
+        if (returnval == false) input.select()
+        return returnval
+}
+</script>
+
 [%- IF ctx.use_stripe %]
 <script type="text/javascript">unHideMe($("pay_fines_now"));[%# the DOM is loaded now, right? %]</script>
 [% END -%]
diff --git a/Open-ILS/src/templates/opac/register.tt2 b/Open-ILS/src/templates/opac/register.tt2
index cb04055..3c2d637 100644
--- a/Open-ILS/src/templates/opac/register.tt2
+++ b/Open-ILS/src/templates/opac/register.tt2
@@ -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;
 
 %]
@@ -96,7 +96,7 @@ END;
                 ) | html %]</h4>
         [% END %]
 
-        <form method='POST'>
+        <form method='POST' onSubmit="return dobValidate(document.getElementById('stgu.dob'))">
             <table>
                 <tr>
                     <td>
@@ -141,7 +141,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 %]

-----------------------------------------------------------------------

Summary of changes:
 Open-ILS/src/templates/opac/parts/js.tt2 |   14 ++++++++++++++
 Open-ILS/src/templates/opac/register.tt2 |    7 ++++---
 2 files changed, 18 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list