@@ -, +, @@ special characters - Add a library with a branchcode containing characters like & or #. - Apply the patch and clear your browser cache if necessary. - Try to delete the new library. It should delete successfully. - Add a library again and try to include spaces and/or special characters in the branchcode. The form validation script should prevent you from submitting the form. - Go do Administration -> Patron categories and add a new patron category. The category code field should prevent you from entering a code with spaces or special characters. --- .../prog/en/includes/validator-strings.inc | 3 +- koha-tmpl/intranet-tmpl/prog/en/js/categories.js | 10 ------- .../prog/en/modules/admin/branches.tt | 34 +++++++++++++--------- .../prog/en/modules/admin/categories.tt | 1 - koha-tmpl/intranet-tmpl/prog/js/staff-global.js | 8 +++++ 5 files changed, 30 insertions(+), 26 deletions(-) --- a/koha-tmpl/intranet-tmpl/prog/en/includes/validator-strings.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/validator-strings.inc @@ -16,7 +16,8 @@ $(document).ready(function(){ rangelength: $.validator.format(_("Please enter a value between {0} and {1} characters long.")), range: $.validator.format(_("Please enter a value between {0} and {1}.")), max: $.validator.format(_("Please enter a value less than or equal to {0}.")), - min: $.validator.format(_("Please enter a value greater than or equal to {0}.")) + min: $.validator.format(_("Please enter a value greater than or equal to {0}.")), + letters_numbers: $.validator.format(_("This field can only contain the following characters: letters, numbers, hyphen, and underscore.")) }); }); //]]> --- a/koha-tmpl/intranet-tmpl/prog/en/js/categories.js +++ a/koha-tmpl/intranet-tmpl/prog/en/js/categories.js @@ -1,13 +1,3 @@ -jQuery.validator.addMethod( "letters_numbers", function(value,element){ - var patt = /^[a-zA-Z0-9\-_]+$/g; - if (patt.test(element.value)) { - return true; - } else { - return false; - } - }, MSG_CATEGORYCODE_CHARS -); - jQuery.validator.addMethod( "enrollment_period", function(){ enrolmentperiod = $("#enrolmentperiod").val(); enrolmentperioddate = $("#enrolmentperioddate").val(); --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt @@ -25,17 +25,15 @@ "sPaginationType": "four_button" })); - [% UNLESS library %] - $("#Aform").on("submit", function( event ) { - if ( $("#branchcode").val().match(/\s/) ) { - event.preventDefault(); - alert(_("The library code entered contains whitespace characters. Please remove any whitespace characters from the library code")); - return false; - } else { - return true; - } - }); - [% END %] + $("#library_entry").validate({ + rules: { + branchcode: { + required: true, + letters_numbers: true + }, + branchname: "required" + } + }); }); tinyMCE.init({ mode : "textareas", @@ -132,7 +130,7 @@ tinyMCE.init({ [% IF op == 'add_form' %]

[% IF library %]Modify library[% ELSE %]New library[% END %]

-
+
[% IF library %] @@ -271,7 +269,11 @@ tinyMCE.init({ [% library.branchip %] Edit - Delete + + + + + [% END %] @@ -302,7 +304,11 @@ tinyMCE.init({ [% category.codedescription |html %] Edit - Delete +
+ + + +
[% END %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt @@ -10,7 +10,6 @@ [% INCLUDE 'datatables.inc' %] --- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js +++ a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js @@ -15,6 +15,14 @@ function formatstr(str, col) { }); } +jQuery.validator.addMethod( "letters_numbers", function(value,element){ + var patt = /^[a-zA-Z0-9\-_]+$/g; + if (patt.test(element.value)) { + return true; + } else { + return false; + } +}); // http://stackoverflow.com/questions/14859281/select-tab-by-name-in-jquery-ui-1-10-0/16550804#16550804 $.fn.tabIndex = function () { --