javascript定义的函数调用时候总是未定义

 调用地方
<input type="number" required="required" class="form-control" id="width" name="advertisingPlace.width" value="${advertisingPlace.width}" onblur="isValidate()"/>
我定义的函数
<script type="text/javascript">
$(function($){
    show();

    $('#edit_form').submit(function() {
        var width = $('#width').val();
        var height = $('#height').val();
        if(width >999 || height >999){
            bootbox.alert({ 
                size: 'small',
                message: "数据不可以超过4位"
            });
            return false;
        }
        return true;
    });
});

function show(){
    var placeId = ${advertisingPlace.placeId };
    var parentId = $('#'+placeId).val();
    var id = ${advertisingPlace.placeId };
    if(parentId == placeId){
        $('#'+id).hide();
    }
}

function isValidate(){
    var width = $('#width').val();
    var height = $('#height').val();
    if(width >999 || height >999){
        bootbox.alert({ 
            size: 'small',
            message: "数据不可以超过4位"
        });
    }
}
</script>
总是提示isValidate函数未定义
Uncaught SyntaxError: Unexpected token ;
Uncaught ReferenceError: isValidate is not defined
请问各位大神,这个是怎么回事

你用到了服务器标签,你这个脚本是放到动态页里面没有,没有下面2个句会出错,而且如果是非数字,要用引号括起,要不语法错误了,导致isValidate就没有生成

 function show(){
    var placeId = '${advertisingPlace.placeId }';///////////////////
    var parentId = $('#'+placeId).val();
    var id = '${advertisingPlace.placeId }';///////////////
    if(parentId == placeId){
        $('#'+id).hide();
    }
}

调用的地方是

图片说明

$(function($){ show(); $('#edit_form').submit(function() { var width = $('#width').val(); var height = $('#height').val(); if(width >999 || height >999){ bootbox.alert({ size: 'small', message: "数据不可以超过4位" }); return false; } return true; }); }); function show(){ var placeId = ${advertisingPlace.placeId }; var parentId = $('#'+placeId).val(); var id = ${advertisingPlace.placeId }; if(parentId == placeId){ $('#'+id).hide(); } } function isValidate(){ var width = $('#width').val(); var height = $('#height').val(); if(width >999 || height >999){ bootbox.alert({ size: 'small', message: "数据不可以超过4位" }); } }

函数是这个,第一次发的怎么显示成那样了

谁便问下,如何将提问的代码规整化,不要像现在这么乱

$(function($) {
show();
$('#edit_form').submit(function() {
var width = $('#width').val();
var height = $('#height').val();
if (width > 999 || height > 999) {
bootbox.alert({
size: 'small',
message: "数据不可以超过4位"
});
return false;
}
return true;
});
});
function show() {
var placeId = $ {
advertisingPlace.placeId
};
var parentId = $('#' + placeId).val();
var id = $ {
advertisingPlace.placeId
};
if (parentId == placeId) {
$('#' + id).hide();
}
}
function isValidate() {
var width = $('#width').val();
var height = $('#height').val();
if (width > 999 || height > 999) {
bootbox.alert({
size: 'small',
message: "数据不可以超过4位"
});
}
}

可能是var id = ${advertisingPlace.placeId}; 中${advertisingPlace.placeId}的值为空。不建议在JS内写EL表达式,会有风险。可以多定义一个标签,
然后里面放EL值,再用$()获取。

谢谢
showbo,问题解决了,是没加 ' '