DateTextBox验证无效

时间:2014-12-10 06:08:32

标签: java spring jsp dojo

我想在用户输入“abcd”之类的无效输入时验证DateTextBox字段。如果用户输入无效输入,我想限制表单提交。

下面是用于验证的代码。但是每当我给出'fromdate'和'todate'时,点击按钮表格就会被正确验证并且提交受限制。但是在'fromdate'日历弹出窗口中,所有日期都被删除了。我想重置约束。

任何帮助将不胜感激。谢谢提前

 function validateForm()
{   alert('Validate');
    var form = dijit.byId("form1");
    alert('form '+form);
    if(form.validate()) {   
        console.info("It was valid!");
    } else {
    var result= alert('The value entered is invalid.Please provide the valid input.');
    if(result= true){

    //
   }


<tr>
            <td class="label"><label
                title="A single Deduction Date can be entered in the From/To fields or a range of Deduction Dates can be entered to search multiple days.">
            Deduction Date From</label></td>
            <td class="content"><form:input
                path="deductionSearchFilter.deductionDateFrom" size='20'
                id="fromDedDate" dojotype="dijit.form.DateTextBox"
                onchange="dijit.byId('toDedDate').constraints.min = arguments[0];"
                size="10" style="width: 114"
                title="A single Deduction Date can be entered in the From/To fields or a range of Deduction Dates can be entered to search multiple days." />
            <span class="required">To </span><form:input
                path="deductionSearchFilter.deductionDateTo" id="toDedDate"
                dojotype="dijit.form.DateTextBox"
                onchange="dijit.byId('fromDedDate').constraints.min = arguments[0];"
                size="10" style="width: 114"
                title="A single Deduction
          Date can be entered in the From/To fields or a range of Deduction Dates can be entered to search multiple days." />

            </td>
        </tr>


<td align='center'><input id="search" onclick="validateForm();" type="submit" name="Search"
                value="Search" class="button"
                title="View the results of search" />
            </td>

0 个答案:

没有答案