Skip to content

Commit 79e55dd

Browse files
authored
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
1 parent 610e249 commit 79e55dd

File tree

27 files changed

+281
-62
lines changed

27 files changed

+281
-62
lines changed

applications/accounting/widget/InvoiceForms.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -636,11 +636,11 @@ under the License.
636636
</service>
637637
</actions>
638638
<field name="invoiceId"><hidden/></field>
639-
<field name="emailAddressFrom" entry-name="mapFrom.emailAddress" parameter-name="sendFrom" use-when="&quot;${invoice.invoiceTypeId}&quot;.equals(&quot;SALES_INVOICE&quot;)"><text/></field>
640-
<field name="emailAddressFrom" entry-name="mapTo.emailAddress" parameter-name="sendFrom" use-when="&quot;${invoice.invoiceTypeId}&quot;.equals(&quot;PURCHASE_INVOICE&quot;)"><text/></field>
641-
<field name="emailAddressTo" entry-name="mapTo.emailAddress" parameter-name="sendTo" use-when="&quot;${invoice.invoiceTypeId}&quot;.equals(&quot;SALES_INVOICE&quot;)"><text/></field>
642-
<field name="emailAddressTo" entry-name="mapFrom.emailAddress" parameter-name="sendTo" use-when="&quot;${invoice.invoiceTypeId}&quot;.equals(&quot;PURCHASE_INVOICE&quot;)"><text/></field>
643-
<field name="emailAddressCc" entry-name="ccEmailAddress" parameter-name="sendCc"><text/></field>
639+
<field name="emailAddressFrom" entry-name="mapFrom.emailAddress" parameter-name="sendFrom" use-when="&quot;${invoice.invoiceTypeId}&quot;.equals(&quot;SALES_INVOICE&quot;)"><text type="email"/></field>
640+
<field name="emailAddressFrom" entry-name="mapTo.emailAddress" parameter-name="sendFrom" use-when="&quot;${invoice.invoiceTypeId}&quot;.equals(&quot;PURCHASE_INVOICE&quot;)"><text type="email"/></field>
641+
<field name="emailAddressTo" entry-name="mapTo.emailAddress" parameter-name="sendTo" use-when="&quot;${invoice.invoiceTypeId}&quot;.equals(&quot;SALES_INVOICE&quot;)"><text type="email"/></field>
642+
<field name="emailAddressTo" entry-name="mapFrom.emailAddress" parameter-name="sendTo" use-when="&quot;${invoice.invoiceTypeId}&quot;.equals(&quot;PURCHASE_INVOICE&quot;)"><text type="email"/></field>
643+
<field name="emailAddressCc" entry-name="ccEmailAddress" parameter-name="sendCc"><text type="email"/></field>
644644
<field name="subject"><text default-value="Please find attached invoice."/></field>
645645
<field name="otherCurrency" entry-name="parameters.other" parameter-name="other"><check/></field>
646646
<field name="bodyText"><textarea/></field>

applications/humanres/widget/forms/EmployeeForms.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
<field name="contactNumber" title="${uiLabelMap.PartyPhoneNumber}" required-field="true"><text size="15" maxlength="15"/></field>
6464
<field name="extension" title="${uiLabelMap.PartyContactExt}"><text size="6" maxlength="10"/></field>
6565
<field name="emailAddressTitle" title="${uiLabelMap.PartyEmailAddress}" title-area-style="group-label"><display/></field>
66-
<field name="emailAddress" title="${uiLabelMap.CommonEmail}"><text size="50" maxlength="60"/></field>
66+
<field name="emailAddress" title="${uiLabelMap.CommonEmail}"><text size="50" maxlength="60" type="email"/></field>
6767
<field name="submitButton" title="${uiLabelMap.CommonSave}" widget-style="smallSubmit"><submit button-type="button"/></field>
6868
</form>
6969
<form name="AddEmployeeSkills" type="single" target="createEmployeeSkill" default-map-name="partySkill">

applications/marketing/widget/sfa/forms/AccountForms.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ under the License.
6464
<field name="contactNumber" title="${uiLabelMap.PartyPhoneNumber}"><text size="15" maxlength="15"/></field>
6565
<field name="extension" title="${uiLabelMap.PartyContactExt}"><text size="6" maxlength="10"/></field>
6666
<field name="emailAddressTitle" title="${uiLabelMap.PartyEmailAddress}" title-area-style="group-label"><display/></field>
67-
<field name="emailAddress" title="${uiLabelMap.CommonEmail}"><text size="50" maxlength="60"/></field>
67+
<field name="emailAddress" title="${uiLabelMap.CommonEmail}"><text size="50" maxlength="60" type="email"/></field>
6868
<field name="submitButton" title="${uiLabelMap.CommonSave}" widget-style="smallSubmit"><submit button-type="button"/></field>
6969
</form>
7070

applications/marketing/widget/sfa/forms/ContactForms.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ under the License.
141141
<field name="contactNumber" title="${uiLabelMap.PartyPhoneNumber}"><text size="15" maxlength="15"/></field>
142142
<field name="extension" title="${uiLabelMap.PartyContactExt}"><text size="6" maxlength="10"/></field>
143143
<field name="emailAddressTitle" title="${uiLabelMap.PartyEmailAddress}" title-area-style="group-label"><display/></field>
144-
<field name="emailAddress" title="${uiLabelMap.CommonEmail}"><text size="50" maxlength="60"/></field>
144+
<field name="emailAddress" title="${uiLabelMap.CommonEmail}"><text size="50" maxlength="60" type="email"/></field>
145145
<field name="contactListTitle" title="${uiLabelMap.MarketingContactList}" title-area-style="group-label"><display/></field>
146146
<field name="contactListId" title="${uiLabelMap.MarketingContactList}">
147147
<drop-down allow-empty="true">

applications/marketing/widget/sfa/forms/LeadForms.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ under the License.
5656
<field name="contactNumber" title="${uiLabelMap.PartyPhoneNumber}"><text size="15" maxlength="15"/></field>
5757
<field name="extension" title="${uiLabelMap.PartyContactExt}"><text size="6" maxlength="10"/></field>
5858
<field name="emailAddressTitle" title="${uiLabelMap.PartyEmailAddress}" title-area-style="group-label"><display/></field>
59-
<field name="emailAddress" title="${uiLabelMap.CommonEmail}"><text size="50" maxlength="60"/></field>
59+
<field name="emailAddress" title="${uiLabelMap.CommonEmail}"><text size="50" maxlength="60" type="email"/></field>
6060
<field name="leadSourceTitle" title="${uiLabelMap.SfaLeadSource}" title-area-style="group-label"><display/></field>
6161
<field name="dataSourceId" title="${uiLabelMap.SfaLeadSource}">
6262
<drop-down allow-empty="true">
@@ -123,7 +123,7 @@ under the License.
123123
<field name="firstName" title="${uiLabelMap.PartyFirstName}" required-field="true"><text size="15"/></field>
124124
<field name="lastName" title="${uiLabelMap.PartyLastName}" required-field="true"><text size="15"/></field>
125125
<field name="groupName" title="${uiLabelMap.CommonGroup}"><text size="15"/></field>
126-
<field name="emailAddress" title="${uiLabelMap.CommonEmail}"><text size="15"/></field>
126+
<field name="emailAddress" title="${uiLabelMap.CommonEmail}"><text size="15" type="email"/></field>
127127
<field name="contactListId" title="${uiLabelMap.MarketingContactList}">
128128
<drop-down allow-empty="true">
129129
<entity-options entity-name="ContactList" key-field-name="contactListId" description="${groovy:contactListName.substring(0,Math.min(contactListName.length(), 12))}..."/>

applications/order/template/entry/CustSettings.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ under the License.
107107
<td width="26%" align="right"><div>${uiLabelMap.PartyEmailAddress}<br/>${uiLabelMap.OrderAllowSolicitation}</div></td>
108108
<td width="5">&nbsp;</td>
109109
<td width="74%">
110-
<input type="text" name="emailAddress" value="" size="60" maxlength="255" />
110+
<input type="text" name="emailAddress" value="" size="60" maxlength="255" type="email"/>
111111
<br/>
112112
<select name="emailSol">
113113
<#if ("Y" == ((requestParameters.emailSol)!""))><option value="Y">${uiLabelMap.CommonY}</option></#if>

applications/party/template/party/EditContactMech.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ under the License.
203203
<tr>
204204
<td class="label">${mechMap.contactMechType.get("description",locale)}</td>
205205
<td>
206-
<input type="text" size="60" maxlength="255" name="emailAddress" value="${(mechMap.contactMech.infoString)?default(request.getParameter('emailAddress')!)}" />
206+
<input type="email" size="60" maxlength="255" name="emailAddress" value="${(mechMap.contactMech.infoString)?default(request.getParameter('emailAddress')!)}" />
207207
</td>
208208
</tr>
209209
<#elseif "FTP_ADDRESS" = mechMap.contactMechTypeId!>

applications/party/widget/partymgr/CommunicationEventForms.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ under the License.
928928
<field name="donePage"><hidden value="${donePage}"/></field>
929929
<field name="communicationEventId"><hidden value="${parameters.communicationEventId}"/></field>
930930
<field name="partyId" entry-name="dummy" tooltip="${uiLabelMap.PartyLeaveEmpty}"><lookup target-form-name="LookupPartyName"/></field>
931-
<field name="emailAddress"><text/></field>
931+
<field name="emailAddress"><text type="email"/></field>
932932
<field name="firstName" position="1"><text/></field>
933933
<field name="middleName" position="2"><text/></field>
934934
<field name="lastName"><text/></field>

applications/product/template/facility/EditContactMech.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ under the License.
221221
<tr>
222222
<td class="label">${uiLabelMap.PartyEmailAddress}</td>
223223
<td>
224-
<input type="text" class="required" size="60" maxlength="255" name="emailAddress" value="${(mechMap.contactMech.infoString)?default(request.getParameter('emailAddress')!)}" />
224+
<input type="email" class="required" size="60" maxlength="255" name="emailAddress" value="${(mechMap.contactMech.infoString)?default(request.getParameter('emailAddress')!)}" />
225225
*</td>
226226
</tr>
227227
<#else>

framework/widget/dtd/widget-form.xsd

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,25 @@ under the License.
14971497
<xs:documentation>Specifies a short hint that describes the expected value of an input field.</xs:documentation>
14981498
</xs:annotation>
14991499
</xs:attribute>
1500+
<xs:attribute name="type" default="text">
1501+
<xs:annotation>
1502+
<xs:documentation>Controls the type attribute on the input element. Limited to a few types. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types</xs:documentation>
1503+
</xs:annotation>
1504+
<xs:simpleType>
1505+
<xs:restriction base="xs:token">
1506+
<xs:enumeration value="text" />
1507+
<xs:enumeration value="number" />
1508+
<xs:enumeration value="email" />
1509+
<xs:enumeration value="url" />
1510+
<xs:enumeration value="tel" />
1511+
</xs:restriction>
1512+
</xs:simpleType>
1513+
</xs:attribute>
1514+
<xs:attribute name="pattern" type="xs:string">
1515+
<xs:annotation>
1516+
<xs:documentation>Controls the pattern attribute of the input element. See https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern</xs:documentation>
1517+
</xs:annotation>
1518+
</xs:attribute>
15001519
</xs:complexType>
15011520
</xs:element>
15021521
<xs:element name="textarea" substitutionGroup="AllFields">

0 commit comments

Comments
 (0)