<xf:alert> does not show for xforms-invalid event
Brought to you by:
alain-couthures
The alert icon does not show (display:none) for any expression of required or constraint attributes in the bind.
This used to work in pre-beta versions.
<xforms:bind id="fname_bind" nodeset="/person-name/first-name" required="true()" constraint="string-length(.) >0"/>
<xforms:input ref="/person-name/first-name">
<xforms:label>First Name:</xforms:label>
<xforms:alert>required!!!</xforms:alert>
</xforms:input>
demo source code
The bug can be only reproduced in Beta 3. I tested in Beta 3 RC and it does not happen. I identified the responsible source code: xsltforms.js (lines 4130 - 4149 XFControl.prototype.changeProp)
This:
this[prop] = value;
if (prop == "notvalid" && nvalue == "") {
value = false;
}
makes the value=false and the .xforms-invalid class is not attached to the span any more.
It has been deliberately chosen not to display both required icon and invalid icon for an empty field.
As a consequence, the alert text cannot anymore be displayed without source modifications.
This should be considered for XSLTForms 1.0 but not for XSLTForms 1.0RC.
Are you using XSLTForms in production?
Thanks!
-Alain
Hi Alan,
Thanks for reply.
As the bind sets the field as required required="true()" and even puts a constraint on it constraint="string-length(.) >0", an empty field can not just be ignored.
The form should not validate the empty field as long as it is on purpose marked not to be empty. This is probably the most basic form validation condition.
Regards, Cristian
Test 6.1.3.a is correct with XSLTForms latest build as the submission is not performed when the input field is empty.