@@ -, +, @@ 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' %]