Bug 11769 - Use validation plugin when creating new MARC framework

The page for adding a new MARC framework includes some custom form
validation JavaScript which can be removed in favor of HTML5 validation
attributes and Koha's built-in validation plugin. This patch does so.

To test, apply the patch and go to Administration -> MARC bibliographic
framework -> New framework. Try submitting the form without entering a
tag number. This should trigger a validation warning.

Submission of the form with valid data should work correctly. Editing an
existing framework should also work correctly.

Patch behaves as expected.
Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
Owen Leonard 2014-02-14 15:17:44 -05:00 committed by Galen Charlton
parent e64c52866b
commit 050a9c97fd
1 changed files with 3 additions and 37 deletions

View File

@ -8,40 +8,6 @@
</title>
[% INCLUDE 'doc-head-close.inc' %]
<script type="text/javascript">
//<![CDATA[
function isNotNull(f,noalert) {
if (f.value.length ==0) {
return false;
}
return true;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function Check(f) {
var ok=1;
var _alertString="";
var alertString2;
if (f.frameworkcode.value.length==0) {
_alertString += "\n- " + _("Framework code missing");
}
if (!(isNotNull(window.document.Aform.frameworktext))) {
_alertString += "\n- " + _("Description missing");
}
if (_alertString.length==0) {
document.Aform.submit();
} else {
alertString2 = _("Form not submitted because of the following problem(s)");
alertString2 += "\n------------------------------------------------------------------------------------\n";
alertString2 += _alertString;
alert(alertString2);
return false;
}
return true;
}
//]]>
</script>
<script type="text/javascript">
/* Import/Export from/to spreadsheet */
var importing = false;
@ -141,7 +107,7 @@ function Check(f) {
[% IF ( add_form ) %]
<h1>[% IF ( frameworkcode ) %]Modify framework text[% ELSE %]Add framework[% END %]</h1>
<form action="[% script_name %]" name="Aform" method="post" onsubmit="return Check(this);">
<form action="[% script_name %]" name="Aform" method="post" class="validated">
<input type="hidden" name="op" value="add_validate" />
<fieldset class="rows">
<ol>
@ -150,10 +116,10 @@ function Check(f) {
<input type="hidden" name="modif" value="1" />
</li>
[% ELSE %]
<li><label for="frameworkcode">Framework code: </label><input type="text" id="frameworkcode" name="frameworkcode" size="4" maxlength="4" onblur="toUC(this)" /></li>
<li><label for="frameworkcode">Framework code: </label><input type="text" id="frameworkcode" name="frameworkcode" size="4" maxlength="4" onblur="toUC(this)" required="required" class="required" /></li>
[% END %]
<li><label for="description">Description: </label>
<input type="text" name="frameworktext" id="description" size="40" maxlength="80" value="[% frameworktext |html %]" /></li></ol></fieldset>
<input type="text" name="frameworktext" id="description" size="40" maxlength="80" value="[% frameworktext |html %]" required="required" class="required" /></li></ol></fieldset>
<fieldset class="action"> <input type="submit" value="Submit" class="submit" /></fieldset>
</form>
[% END %]