我想使用jsp验证用户在文本框中给出的值

时间:2018-04-13 11:01:50

标签: javascript java jquery jsp

如何验证Textbox?代码如下。

我在行中创建了一个表格和文本框。我想验证该文本框。用户无法在{name="min[<%=i%>]"}文本框中输入小于{name="max[<%=i%>]"}的数据。并且数据最小和最大为{name="normal[<%=i%>]"}文本框

<%  
    Connection con = null;              
    con = connection.createConnection();
    System.out.println("Printing connection object "+con);
    Statement statement=con.createStatement(); 

    String sql ="SELECT * 
        FROM `itemfile` 
        WHERE IT_ITEMGRP IN ('A', 'K', 'T','M')";
    rs = statement.executeQuery(sql);
%>

<form class="form-horizontal" action="dailyEntryServ" name="registration" id="registration" method="get">
    <h4><u>દૈનિક એન્ટ્રી</u></h4>
    <h4 align="right">
        <span style="color:red">
            <b>
                <%=(request.getAttribute("errMessage") == null) ? "": request.getAttribute("errMessage")%>
            </b>
        </span>
        <br/>
        <span style="color:green">
            <b>
                <%=(request.getAttribute("successMessage") == null) ? "": request.getAttribute("successMessage")%>
           </b>
        </span>
    </h4>
    <div class="col-md-12">
        <div class="form-group">
            <label class="control-label col-sm-4" for="date">Select Date:</label>
            <div class="col-sm-3">
                <input class="datepicker" data-date-format="yyyy-mm-dd" placeholder="yyyy-mm-dd" id="date" name="date" value="<%=strDate%>">
            </div>
        </div>
        <table align="center" cellpadding="" cellspacing="" border="1" id="oTable" width="100%">
            <thead>
                <tr>
                    <th>ક્રમ નં</th>
                    <th>જણસી નું નામ</th>
                    <th>ઓછામાં ઓછો ભાવ(કવી.)</th>
                    <th>વધુમાં વધુ ભાવ(કવી.)</th>
                    <th>મોડલ ભાવ(કવી.)</th> 
                    <th>આવક</th>                            
                </tr>
            </thead><%

                int i=0;
                while(rs.next()) {
                    String code=rs.getString("IT_ITEMCOD");
                    String id=rs.getString("IT_ITEMSUB");                        
                    //String grp=rs.getString("IT_ITEMGRP"); 
                    String good=code+"."+id; 

                    %><tr>
                        <td><%=++i%></td>
                        <td>
                            <label style="font-family: gujratilys;font-weight: normal;font-size: 14px;">
                                <%=rs.getString("IT_ITMSNMG") %>
                            </label>
                        </td>
                        <td>
                            <input type="hidden" width="100%" id="cols[<%=i%>]" name="cols[<%=i%>]" value="<%=good %>" />
                            <input type="text" width="100%" id="max[<%=i%>]" name="max[<%=i%>]" value="0"/>
                        </td>
                        <td>
                            <input type="text" width="100%" id="min[<%=i%>]" name="min[<%=i%>]" value="0"/>
                        </td>
                        <td>
                            <input type="text" width="100%" id="normal[<%=i%>]" name="normal[<%=i%>]" value="0"/>
                        </td> 
                        <td>
                            <input type="text" width="100%" id="aavak[<%=i%>]" name="aavak[<%=i%>]" value="0"/>
                        </td>
                    </tr><% 
                }
                rs.close();

                %><tr>
                    <input type="hidden" id="size" value=" <%=i%>" name="size" />
                    <td colspan="6" align="center">
                        <button type="submit" class="btn btn-success">Submit</button>
                    </td>
                </tr>

            <tbody>
            </tbody>
        </table>
    </div>
</form>     

0 个答案:

没有答案