[open-ils-commits] [GIT] Evergreen ILS branch rel_2_7 updated. 2bf9a90ebd144a26a3dc39c100fecd3dd05c430a

Evergreen Git git at git.evergreen-ils.org
Fri Sep 4 11:53:26 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, rel_2_7 has been updated
       via  2bf9a90ebd144a26a3dc39c100fecd3dd05c430a (commit)
      from  ce1b5aaf0aedd46b29fc923616e8f354a8890100 (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 2bf9a90ebd144a26a3dc39c100fecd3dd05c430a
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