对于电话号码验证,我在屏蔽输入插件(jquery)中缺少什么功能?

发布于 2024-12-29 15:27:37 字数 1488 浏览 0 评论 0原文

我在prototype.js 中进行了此操作,但它与一些脚本文件发生冲突。这就是我使用 http://digitalbush.com/projects/ 在新脚本中设置它的方法masked-input-plugin/

<script src="jquery.js" type="text/javascript"></script>
<script src="jquery.maskedinput.js" type="text/javascript"></script>

<script type="text/javascript" language="javascript">

  jQuery(function($){
  $("#phone").mask("(999)999-9999");
  $.mask.definitions['~']='[+-]';
  $("#eyescript").mask("~9.99 ~9.99 999");
  });

</script>

根据我在prototype.js中的脚本,这显然缺少一些东西,这是我必须删除的一个示例。

<script type="text/javascript" src="/media/system/js/prototype.js"></script>
<script type="text/javascript" src="/media/system/js/prototype.maskedinput.js"></script>

<script type="text/javascript">
Event.observe(window, 'load', function() {

    new MaskedInput('#phone', '(999)999-9999');

    new MaskedInput('#eyescript', '~9.99 ~9.99 999', {
        completed: function(){
            alert("You typed the following: " + this.getValue());
        }
    });

    MaskedInput.definitions['~']='[+-]';

    new MaskedInput('#eyescript2', '~9.99 ~9.99 999', {
        completed: function(){
            alert("You typed the following: " + this.getValue());
        }
    });
});
</script>

就像我说的,这个脚本确实有效,但给我带来了与太多东西(mootools/jquery)的冲突,所以我想让 jquery 版本适用于此操作,看看它是否解决了问题。

I had this working in prototype.js but it conflicted with a few script files. This is how I set it up in the new script using http://digitalbush.com/projects/masked-input-plugin/

<script src="jquery.js" type="text/javascript"></script>
<script src="jquery.maskedinput.js" type="text/javascript"></script>

<script type="text/javascript" language="javascript">

  jQuery(function($){
  $("#phone").mask("(999)999-9999");
  $.mask.definitions['~']='[+-]';
  $("#eyescript").mask("~9.99 ~9.99 999");
  });

</script>

This is obviously missing something based on my script in prototype.js, here is an example I had to remove.

<script type="text/javascript" src="/media/system/js/prototype.js"></script>
<script type="text/javascript" src="/media/system/js/prototype.maskedinput.js"></script>

<script type="text/javascript">
Event.observe(window, 'load', function() {

    new MaskedInput('#phone', '(999)999-9999');

    new MaskedInput('#eyescript', '~9.99 ~9.99 999', {
        completed: function(){
            alert("You typed the following: " + this.getValue());
        }
    });

    MaskedInput.definitions['~']='[+-]';

    new MaskedInput('#eyescript2', '~9.99 ~9.99 999', {
        completed: function(){
            alert("You typed the following: " + this.getValue());
        }
    });
});
</script>

Like I said, this script did work but gave me conflicts with too many thing (mootools/jquery) so I want to make the jquery version work for this action instead and see if it resolves the issue.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

日记撕了你也走了 2025-01-05 15:27:37

我能够让它与这个一起工作......

<script type="text/javascript">// <![CDATA[
  jQuery(function($) {
  $.mask.definitions['~']='[+-]';
  $('#phone').mask('(999)999-9999');
  $("#product").mask("a*-999-a999",{placeholder:" ",completed:function(){alert("You typed the following: "+this.val());}});
  $("#eyescript").mask("~9.99 ~9.99 999");
   });
// ]]></script>

I was able to get it working with this...

<script type="text/javascript">// <![CDATA[
  jQuery(function($) {
  $.mask.definitions['~']='[+-]';
  $('#phone').mask('(999)999-9999');
  $("#product").mask("a*-999-a999",{placeholder:" ",completed:function(){alert("You typed the following: "+this.val());}});
  $("#eyescript").mask("~9.99 ~9.99 999");
   });
// ]]></script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文