下拉列表和文本框的验证问题

时间:2015-03-24 05:30:23

标签: javascript jquery validation jsp

我有4个下拉列表框,即year,make,model,sumbodel和一个文本框(即)里程,如果我选择年份和里程而不选择其他,则应显示错误消息。但它正在重定向到结果页面。如何停止重定向到结果页面,它必须显示错误消息

if ( typeof ScheduledMaintenance.scheduledMaintenanceForm !== 'function' ) {
    ScheduledMaintenance.scheduledMaintenanceForm = {
        submitScheduledMaintenanceForm : function () {
            var acesVehicleId = this.sanitizeScheduledMaintenanceURLNumber($("#acesVehicleIdHidden").val());
            var year = this.sanitizeScheduledMaintenanceURLNumber($("#year option:selected").text());
            var make = this.sanitizeScheduledMaintenanceURLString($("#make option:selected").text());
            var model = this.sanitizeScheduledMaintenanceURLString($("#model option:selected").text());
            var submodel = this.sanitizeScheduledMaintenanceURLString($("#submodel option:selected").text());
            var mileage = this.sanitizeScheduledMaintenanceURLNumber($("#mileage").val());

            var scheduledMaintenanceURL = "/vehicle-scheduled-maintenance/"+acesVehicleId;
            if (mileage != null && mileage.length > 0) {
                scheduledMaintenanceURL += "/"+mileage;
            }
            scheduledMaintenanceURL += "/"+year+"-"+make+"-"+model;
            if (submodel != null && submodel.length > 0 && submodel != "Default") {
                // some submodels consist of nothing but special characters, so don't use those
                scheduledMaintenanceURL += "-"+submodel;
            }
            scheduledMaintenanceURL += "/listServices.htm";

            window.location = scheduledMaintenanceURL;
        },

0 个答案:

没有答案