AnsweredAssumed Answered

Form field validation handler issue

Question asked by afielden on Jan 25, 2019
Latest reply on Jan 30, 2019 by afielden

I'm hoping someone here can help out with this problem, because I've done everything as per the book, to use a Javascript function to validate a form field. Here's what I've done:


Altered the share-config-custom.xml file, as follows:



    <js src="js/date-range-validator.js" />



    <field id="myfield:dfc-start-date">
        <constraint type="MANDATORY" validation-handler="myspace.forms.validation.checkDateRangeValidity" event="keyup"/>





Created a date-range-validator.js file, which I placed in src/main/assembly/web/js



if (typeof fbs == "undefined" || !fbs) {
  var fbs = {};


myspace.forms.validation.checkDateRangeValidity = function checkDateRangeValidity(field, args, event, form, silent, message) {
  var valid = true;

  alert('Checked date ' + field);

return valid;


However, when the form is displayed I get an exception because "myspace" isn't defined, so it looks like my validator code isn't being loaded. I've tried placing the Javascript file in a variety of locations within the project, but the problem still persists.