登录文本字段中不允许有空格,请使用jquery阻止文本文件中的空格,(解决方案) [英] Space not allowed in login textfield, prevent space in textfile using jquery, (solution)

查看:89
本文介绍了登录文本字段中不允许有空格,请使用jquery阻止文本文件中的空格,(解决方案)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

防止文本字段出现空格的解决方案
-------------------------

solution of prevent space in textfield
-------------------------

<script type="text/javascript">

        $(document).ready(function () {
            $("#txtLogin").keydown(function (event) {
                if (event.keyCode == 32) {
                    event.preventDefault();
                }
            });
        });
    
    </script>


其中#textLogin是文本文件的ID..........


where #textLogin is ID of textfile..........

推荐答案

(文档 ).ready(函数(){
(document).ready(function () {


(" #txtLogin").keydown(如果(event.keyCode == 32 ){ event.preventDefault(); } }); }); </script>
("#txtLogin").keydown(function (event) { if (event.keyCode == 32) { event.preventDefault(); } }); }); </script>


其中#textLogin是文本文件的ID.............


where #textLogin is ID of textfile..........


这看起来像是您要与他人共享的提示.

以提示/技巧的形式发布在这里: http://www.codeproject.com/script/Articles/Submit.aspx [ ^ ]
This looks like a Tip that you want to share with others.

Post here as a Tip/Trick: http://www.codeproject.com/script/Articles/Submit.aspx[^]


这篇关于登录文本字段中不允许有空格,请使用jquery阻止文本文件中的空格,(解决方案)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆