[ 
https://issues.apache.org/jira/browse/OFBIZ-13183?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jacques Le Roux reassigned OFBIZ-13183:
---------------------------------------

    Assignee: Jacques Le Roux

> 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
>            Assignee: Jacques Le Roux
>            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