[ 
https://issues.apache.org/jira/browse/OFBIZ-13183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17906113#comment-17906113
 ] 

ASF subversion and git services commented on OFBIZ-13183:
---------------------------------------------------------

Commit 79e55dd6e1790211f3a14710caa2947adb1ce5d3 in ofbiz-framework's branch 
refs/heads/trunk from Florian Motteau
[ https://gitbox.apache.org/repos/asf?p=ofbiz-framework.git;h=79e55dd6e1 ]

Improved: Use browser validation for input element, support types (#862)

* Improved: Use browser validation for input element, support types

Rely on browser native validation for inputs, using the "required"
attribute, instead of jQuery Validation plugin.
Support "number", "email", "url" and "tel" input types.
Support "pattern" attribute for input types that supports it.
Fix boolean attributes uses in FTL macros ("readonly", "required").
Fix required behavior when "required-field-style" is not empty.
Add "required" attribute on password fields.
Add "required" attribute to inputs in login forms

OFBIZ-13183

* Improved: Use input type=number for numeric fields

OFBIZ-13183

* Adjust new input types appearance

OFBIZ-13183

* Use input type "email" instead of "text" for email fields

OFBIZ-13183

* Fix checkstyle issues

OFBIZ-13183

* Fix XSD issue

You can't have both type="xs:string" and a nested complexType for the same 
element.

OFBIZ-13183

* Always add an asterisk on mandatory fields

Even if we defined a "required-field-style" attribute

OFBIZ-13183

* Fix test on required-field-style attribute

OFBIZ-13183

* Update renderAsterisks macro declarations

OFBIZ-13183

> Form inputs: use "required" attribute on mandatory fields, validation breaks 
> if "required-field-style" is not empty
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: OFBIZ-13183
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-13183
>             Project: OFBiz
>          Issue Type: Bug
>          Components: ALL APPLICATIONS
>    Affects Versions: 18.12.17, Upcoming Branch
>            Reporter: Florian Motteau
>            Priority: Minor
>         Attachments: image-2024-11-20-15-22-39-357.png, 
> image-2024-11-20-15-24-34-744.png, screenshot-1.png
>
>
> When setting the XML "required-field" attribute to "true" on a form field 
> (making a field mandatory), the form rendering process does the following :
> * if the XML attribute "required-field-style" is absent, we add "required" as 
> a CSS class on the input, which gives a light yellow background to the input 
> on Rainbowstone,
> * this class will trigger the asterisk next to the input and the jQuery 
> Validation plugin that will ensure that the field is not empty (alongside 
> potential other rules I guess)
> * if the "required-field-style" attribute is present, then the input gets the 
> value of this attribute as a CSS class, without the "required" class, 
> therefore we won't get any validation on this field (even though we gave him 
> the "required-field" XML attribute), and we will be able to submit the form 
> with an empty field (this is why I would describe this as a bug),
> * more surprisingly, regardless of the presence of the "required-field" or 
> "required-field-style" attributes, all inputs (maybe other form elements ?) 
> get a "require" attribute, which is not a valid attribute for an input tag 
> (see input macro in HtmlFormMacroLibrary.ftl)
> I would suggest :
> * to give the HTML "required" attribute on elements if "required-field" is 
> true (for all HTML element that support it, see 
> https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/required)
> * to remove the unconditional "require" attribute on input fields (invalid, 
> and AFAIK ununsed),
> * to keep the "required" CSS class on inputs when "required-field" is true 
> and "required-field-style" is not null, so client side validation (with 
> jQuery module) won't break
> IMHO, it would be a good thing to only rely on the HTML "required" attribute 
> to ensure that a mandatory field is not empty, and get rid of the jQuery 
> validation at least for required fields. With the "required" attribute, if 
> field is empty, the form submission is blocked, and the browser displays a 
> message :
>  !image-2024-11-20-15-24-34-744.png! 
> At least it should be the common-theme behavior.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to