在表单提交上使用jquery set datepicker值为“”

时间:2013-05-13 08:13:03

标签: javascript jquery validation datepicker

我有一个jsp代码,在提交时调用此函数

function filterExcessPage() {
    setDefaultValues();
    var fromLast =document.getElementById('fromLast').value;
    var fromDate =document.getElementById('fromDate').value;
    var toDate =document.getElementById('toDate').value;
    $("#excessListForm").submit(function() {
        if((toDate.length>0) && (fromDate.length==0)) { 
            $('#validateDate').text('*from date is mandatory');
            return false;
        }else if ((fromDate.length>0) && (new Date(fromDate)>new Date())) {
            $('#validateDate').text('*from date should be less than current date');
            excessListForm.fromDate.value="";
            return false;
        }else if ((toDate.length>0) && (new Date(toDate)>new Date())) {
            $('#validateDate').text('*to Date should be less than current date');
            excessListForm.toDate.value="";
            return false;
        }else {
            var queryUrl = "/excessManagement.web/inbox.htm?excessFilteredData=true&fromLast=" + fromLast+"&fromDate="+fromDate+"&toDate="+toDate;
            excessListForm.action =  queryUrl;
            excessListForm.submit();
        }
    });

}

function setDefaultValues() {
    excessListForm.cif.value="";
    excessListForm.customerName.value="";
    excessListForm.fromLast.value="";
    excessListForm.fromDate.value="";
    excessListForm.toDate.value="";     
}

表单提交时,fromdate和todate值重新出现.... 表单提交后,fromdate,todate文本框中显示的值采用我在java类中使用的格式.... 我需要在表单提交后将值设置为“”...

1 个答案:

答案 0 :(得分:0)

在客户端设置

  var fromDate =document.getElementById('fromDate').value;
    var toDate =document.getElementById('toDate').value;

fromDate.value= "";
toDate.value =""