在html中,选择标签具有 必需的 属性“指定用户在提交表单之前需要选择一个值”。 在这里阅读

在Struts 1中,“ html:select”标签没有属性”必需的": 在这里阅读

如何在为选择框中提交支撑杆1中的表单之前指定用户选择一个值?

<td class="insdataheader">
    <label for="initReqList[0].seqType">
         <bean:message bundle="XYZ" key="it.myproject.cbi2.disposals.v000104.model.MndtInitiationRequestV02.seqType"/>
    </label>
</td>

<td class="insdatitxt_inserita_nowrap" align="left">
    <html:select property="initReqList[0].seqType" name="initReqList[0].seqType" styleId="initReqList[0].seqType" value="${dataEntryForm.initReqList[0].seqType}">
          <html-ext:keyOptionsCollection bundle="XYZ" name="dataEntryForm" property="initReqList[0].seqTypeOptions" label="keyBundle"value="key"  
   </html:select>
</td>
有帮助吗?

解决方案

尝试这样的事情,JavaScript

jQuery

 $(function(){
            var elem = document.getElementsByName('initReqList[0].seqType')[0];
            jQuery(elem).attr('required','required');
        });

如果需要在htmt tld中需要编辑html tld,并且必须向其添加自定义代码和各自的Java类

其他提示

添加 required 属性 <html:select /> 标签,您必须有一个空的选项。

例子:

<html:select required="required" property="initReqList[0].seqType" name="initReqList[0].seqType" styleId="initReqList[0].seqType" value="${dataEntryForm.initReqList[0].seqType}">
    <html-ext:keyOptionsCollection bundle="XYZ" name="dataEntryForm" property="initReqList[0].seqTypeOptions" label="keyBundle"value="key"  
</html:select>

这对我有用 - 将第一个值空为空 - 需要在空值上工作。

<select required>
 <option value="">Please select</option>
 <option value="one">One</option>
 <option value="two">Two</option>
</select>

所需的属性是布尔属性。指定后,将要求用户在提交表单之前选择一个值。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top