Javascript maskedinput Uncaught TypeError: $(...).mask 不是函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33223283/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
maskedinput Uncaught TypeError: $(...).mask is not a function
提问by Susana Santos
Good afternoon On my there is
下午好 在我那里
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript" src="{{ asset('bundles/reflorestasite/js/jquery.maskedinput.min.js') }}"></script>
<script type="text/javascript" src="{{ asset('bundles/reflorestasite/js/validacoes.js') }}"></script>
<script type="text/javascript" src="{{ asset_url }}"></script>
And on "validacoes.js" file there is
在“validacoes.js”文件上有
$(document).ready(function(){
$(".cpf").mask("999.999.999-99");
$('.cpf').blur(function () {
var id=$(this).attr("id");
var val=$(this).val();
var pattern = new RegExp(/[0-9]{3}[\.]?[0-9]{3}[\.]?[0-9]{3}[-]?[0-9]{2}/);
if(val.match(pattern) == null){
$("#"+id+"_error").html("Digite um CPF válido");
}
});
});
I've already verifed at console and all javascript files are there. However i'm getting the error "Uncaught TypeError: $(...).mask is not a function"
我已经在控制台进行了验证,所有 javascript 文件都在那里。但是我收到错误“Uncaught TypeError: $(...).mask is not a function”
Does anyone has a clue why symfony is not recognizing the maskedinput plugin?
有没有人知道为什么 symfony 无法识别 maskedinput 插件?
Thankyou very much.
非常感谢。
回答by Martins Oyebode
Change this line from
将这一行从
$(document).ready(function(){
to
到
$(document).ready(function($){
回答by user3311636
I got this same error too, but in my case I forgot to import maskedinput.min.js
我也遇到了同样的错误,但就我而言,我忘记导入 maskedinput.min.js
<script src="/js/jquery.maskedinput.min.js" type="text/javascript"></script>
And I was searching Google for a solution haha.
我正在谷歌搜索解决方案哈哈。
回答by Павел Еременко
I solved my problem, I had to remove duplicate script connections
我解决了我的问题,我不得不删除重复的脚本连接
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="/js/jquery.maskedinput-1.3.min.js"></script>