load dhtmlxform from xml template required="true"

Hello dhtmlx’folks!

Apart from form.setRequired(id,true) method, I saw there is another way of setting an input field as required, within the xml template.

I’ve tried

" and

, with and withour the double quotes. The first option does not work, and the second definetely reports an error of

.

So i do not know where the problem is and I would really appreciate any help.

Thank you very much.

Btw, I enclose the code fragment in the xml:

<?xml version="1.0" encoding="UTF-8"?> <items> <item type="fieldset" name="data" label="Información general" inputWidth="auto"> <item type="input" name="numeroRubricas" label="Número de rúbricas/partes" labelWidth="140" required="true" /> <item type="input" name="codigo" label="Código" labelWidth="140" required="true"/> <item type="input" name="curso" label="Curso" labelWidth="140" required="true" /> </item> <item type="button" name="siguiente" value="Siguiente" /> </items>

Hello pecas,

I would also try required=“yes” and required=“1”

Not sure why required=“true” doesn’t work. Personally, I use json structure to initialize a form. In almost all cases except multiselect required: true works for me.

You can initialize your form using json in the following way:

var form_items = [
    {type: 'fieldset', name: 'data', label: 'Información general', list: [
        {type: 'settings', labelWidth: 140},
        {type: 'input', name: 'numeroRubricas', label: 'Número de rúbricas/partes', required: true},
        {type: 'input', name: 'codigo', label: 'Código', required: true},
        {type: 'input', name: 'curso', label: 'Curso', required: true},
    ]},
    {type: 'button', name: 'siguiente', value: 'Siguiente'}
];
var form = new dhtmlXForm("form_container", form_items);

Hope that helps.

Hi to all

Local tests works fine with required=“true”, with “yes” and with “1”
If you will provide completed demo we will check what’s wrong

Hi,

and sorry for the late response. What do you mean by complete demo? I can send you the jsp and the xml template of the form which is used in the jsp. Is that fine??

Thank you very much.

almost. please include all corresponding js.css files also
here is a doc docs.dhtmlx.com/doku.php?id=othe … leted_demo

Hi,

here’s the demo, hope is correctly constructed. thank you very much
Complete Demo.7z (419 KB)

Hi

sorry for long response. please check attached demo.

seems like version of your compiled dhtmlx.js is 3.0, and form do not have “required” functionality for this version. I attached latest 3.6, should work now. please download latest version from our site or request it at our sales team via support system.

updated/new files:

codebase/dhtmlxform.js codebase/dhtmlxform_dyn.js codebase/skins/dhtmlxform_dhx_skyblue.css codebase/imgs/dhxform_dhx_skyblue/*
95.ZIP (719 KB)

Hi,

Thank you very much. This solved the issue: with setRequired method, it works. Although, still not working with required=“true” in the xml template…

Hi

as I already mentioned - you need to update library version, 3.0 doesn’t have requested functionality

Yes, I know, and I did it, thank you; and now it works with setting the input to required in the following way:

form.setRequired(id,true)

But still not working with:
required=“true” in the XML.

Any hints please??

Hi

please check demos attached for 3.6 and for 4.0 versions

  1. you need to open them under serserver otherwise xml will not loaded at all
  2. maybe on your side xml cached? 4.0 will ad no_cache signs automaticaly, in 3.6 you will find &etc=new Date().getTime()
    demo_4.0.zip (408 KB)
    demo_3.6.zip (45.1 KB)