Owen Leonard
97d4689772
This patch adds some custom validation to the MARC tag and subfield fields so that they are limited to alphanumeric characters. Both templates (the main view and the edit view) have been modified so that item_search_fields.js can be included in both. To test, apply the patch and test the form by entering a variety of different character combinations. The "MARC field" and "MARC subfield" inputs should only accept alphanumeric entries. Test both "new" and "edit" operations. Test other operations like delete and cancel. Signed-off-by: Mark Tompsett <mtompset@hotmail.com> Signed-off-by: Jose-Mario <jose-mario.monteiro-santos@inLibro.com> Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
57 lines
1.6 KiB
JavaScript
57 lines
1.6 KiB
JavaScript
/* global _ MSG_ITEM_SEARCH_DELETE_CONFIRM */
|
|
|
|
jQuery.validator.addMethod("marcfield", function(value, element) {
|
|
return this.optional(element) || /^[0-9a-zA-Z]+$/.test(value);
|
|
}, _("Please enter letters or numbers") );
|
|
|
|
$(document).ready(function(){
|
|
$("#add_field_form").hide();
|
|
$("#new_search_field").on("click",function(e){
|
|
e.preventDefault();
|
|
$("#add_field_form").show();
|
|
$(".dialog").hide();
|
|
$("#search_fields_list,#toolbar").hide();
|
|
});
|
|
$(".hide_form").on("click",function(e){
|
|
e.preventDefault();
|
|
$("#add_field_form").hide();
|
|
$(".dialog").show();
|
|
$("#search_fields_list,#toolbar").show();
|
|
});
|
|
$(".field-delete").on("click",function(){
|
|
$(this).parent().parent().addClass("highlighted-row");
|
|
if (confirm( __("Are you sure you want to delete this field?") )) {
|
|
return true;
|
|
} else {
|
|
$(this).parent().parent().removeClass("highlighted-row");
|
|
return false;
|
|
}
|
|
});
|
|
|
|
$("#add_field_form").validate({
|
|
rules: {
|
|
label: "required",
|
|
tagfield: {
|
|
required: true,
|
|
marcfield: true
|
|
},
|
|
tagsubfield: {
|
|
marcfield: true
|
|
}
|
|
}
|
|
});
|
|
|
|
$("#edit_search_fields").validate({
|
|
rules: {
|
|
label: "required",
|
|
tagfield: {
|
|
required: true,
|
|
marcfield: true
|
|
},
|
|
tagsubfield: {
|
|
marcfield: true
|
|
}
|
|
}
|
|
});
|
|
|
|
});
|