0

在 View.jsp 中,我使用 . 上面有一些输入和 3 个选择框,实际上我想验证所有这些。对于我使用的输入,但我不知道如何验证我的

其实我想验证这三个:

  1. <aui:select id="birthday_day" name="birthday_day">
  2. <aui:select id="birthday_month" name="birthday_month">
  3. <aui:select id="birthday_year" name="birthday_year">

这是我的 view.jsp

        <portlet:actionURL var="myUrl">
    </portlet:actionURL>
<aui:form enctype="multipart/form-data" action="<%= myUrl %>" method="POST" name="fm">
 <table border="0" bgcolor=#ccFDDEE>
        <tr>
            <td colspan="2" align="center"><b>Recruiment Form</b></td>
        </tr>
        <tr>
            <td colspan="2" align="center"></td>
        </tr>
        <tr>
            <td><b>First Name:<span>*</span></b></td>
            <td>
                <aui:input name="fname" type="text">
                    <aui:validator name="required"/>
                </aui:input>
            </td>
        </tr>

        <tr>
            <td><b>Last Name:<span>*</span></b></td>
            <td>
                <aui:input name="lname" type="text">
                    <aui:validator name="required"/>
                </aui:input>
            </td>
        </tr>
        <tr>
            <td><b>Father Name:<span>*</span></b></td>
            <td>
                <aui:input name="father_name" type="text">
                    <aui:validator name="required"/>
                </aui:input>
            </td>
        </tr>
        <tr>
            <td><b>Birth Date:<span>*</span></b></td>
            <td>
                <aui:select id="birthday_day" name="<portlet:namespace/>birthday_day">
                    <aui:option value="0">روز</aui:option>
                    <%
                        for(int i=1;i<=31;i++) {
                    %>
                    <aui:option value="<%=i%>"><%=i%></aui:option>
                    <%
                        }
                    %>
                </aui:select>
                /
                <aui:select id="birthday_month" name="birthday_month">
                    <aui:option value="0">ماه</aui:option>
                    <%
                        String[] monthBirthDay = {"فروردین","اردیبهشت","خرداد","تیر","مرداد","شهریور","مهر","آبان","آذر","دی","بهمن","اسفند"};
                        for(int j=0;j<monthBirthDay.length;j++) {
                    %>
                    <aui:option value="<%=j+1%>"><%=monthBirthDay[j]%></aui:option>
                    <%
                        }
                    %>
                </aui:select>
                /
                <aui:select id="birthday_year" name="birthday_year">
                    <aui:option value="0">سال</aui:option>
                    <%
                        String[] yearBirthDay = {"1370","1369","1368","1367","1366","1365","1364"};
                        for(int j=0;j<yearBirthDay.length;j++) {
                    %>
                    <aui:option value="<%=yearBirthDay[j]%>"><%=yearBirthDay[j]%></aui:option>
                    <%
                        }
                    %>
                </aui:select>
            </td>
        </tr>
  </table>
</aui:form>

我该如何解决这个问题??????请指导我。

4

2 回答 2

1

只需为 aui:select 标签分配一个 id

<aui:select inlineField="true" label="xxx" name="xxx" id="xxxId">

然后你可以用这个(javascript + AUI)获得价值

var selectedVal = A.one('#<portlet:namespace/>xxxId').val();

使用选定的值,您可以执行任何类型的验证。

于 2013-12-16T09:34:39.307 回答
1
<aui:select showEmptyOption="true" name="select hospital name" required="true">

</aui:select>

这可能会对您有所帮助。

于 2015-10-01T13:42:29.643 回答