调用地方
<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
请问各位大神,这个是怎么回事

javascript定义的函数调用时候总是未定义
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
8条回答 默认 最新
- 斯洛文尼亚旅游 2016-12-29 01:27关注
你用到了服务器标签,你这个脚本是放到动态页里面没有,没有下面2个句会出错,而且如果是非数字,要用引号括起,要不语法错误了,导致isValidate就没有生成
function show(){ var placeId = '${advertisingPlace.placeId }';/////////////////// var parentId = $('#'+placeId).val(); var id = '${advertisingPlace.placeId }';/////////////// if(parentId == placeId){ $('#'+id).hide(); } }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报