LP1164720 - Do not allow a list to be created with no name user/catalystit/lp1164720
authorKyle Tomita <ktomita@catalystitservices.com>
Fri, 24 May 2013 17:50:05 +0000 (10:50 -0700)
committerKyle Tomita <ktomita@catalystitservices.com>
Fri, 24 May 2013 17:50:05 +0000 (10:50 -0700)
Added a Javascript function to validate the list name field.
A valid name must be entered and cannot contain only spaces.

Signed-off-by: Kyle Tomita <ktomita@catalystitservices.com>
Open-ILS/src/templates/opac/myopac/lists.tt2

index 0b2977d..1abfac1 100644 (file)
                     <a href="javascript:void(0);" onclick="alert(document.getElementById('bb_publish_text').innerHTML);"><img alt="[% l('Sharing Help') %]"
                         src="[% ctx.media_prefix %]/images/question-mark.png" /></a>
                 </td>
+                <script type='text/javascript'>
+                    function notEmpty(elem, msg){
+                        var removedWhiteSpace = elem.value.replace(/\s/g, '');
+                        if(0 == removedWhiteSpace.length){
+                            alert(msg);
+                            elem.value = '';
+                            return false;
+                        }
+                        return true;
+                    }
+                </script>
                 <td class="list-create-table-buttons">
                     <input type="submit"
                         value="[% l('Submit') %]"
                         alt="[% l('Submit') %]"
-                        class="opac-button"/>
+                        class="opac-button"
+                        onClick="if(notEmpty(document.getElementById('list_create_name'), '[% l('Please enter a valid name for your list.') %]')) return true; return false"
+                        />
                     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                     <input type="reset"
                         value="[% l('Cancel') %]"