欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

javascript 全角轉(zhuǎn)換實現(xiàn)代碼

 更新時間:2009年07月17日 00:58:24   作者:  
當(dāng)客戶端用戶切換輸入法至全角時可能您的表單提交會有漏洞哦!不過事實上js有這功能 可以將其轉(zhuǎn)換為非全角字符!
下面我們來看下這個例子吧!
復(fù)制代碼 代碼如下:

<html>
    <head>
        <title>jqueryDemo:quanjiaoNum</title>
        <script src="jquery.js" src="jquery.js" type="text/javascript"></script>
        <script type="text/javascript"><!--
            function changeNum(){
                var qjNum=$("input[@name=qjNum]").val();
                var toAscii=qjNum.charCodeAt();
                if(toAscii > 65295 && toAscii < 65306 && qjNum.length == 11)
                {
                    var toBack = 0;
                    var temp = 0;
                    var unite = "";
                    for(var i=0;i < qjNum.length;i++)
                    {
                        toAscii=qjNum.charCodeAt(i);
                        toBack =toAscii-65248;
                        temp = String.fromCharCode(toBack);
                        unite = unite + temp ;
                    }
                    alert(unite);
                    return true;
                }
                if(toAscii > 47 && toAscii < 58 && qjNum.length == 11)
                {
                    alert(qjNum);
                    return true;
                }
                else{
                    alert("請輸入正確的手機號碼");
                    document.myform.qjNum.value="";
                    return false;
                }
            }

// --></script>
    </head>
    <form name="myform" action="">
        中文數(shù)字轉(zhuǎn)換成阿拉伯?dāng)?shù)字:<input type="text" id="qjNum" name="qjNum"/><input type="button" value="提 交" onclick="changeNum()"/>
    </form>
</html>

這是個判斷手機號的問題!另外請注意我這還用到了jquery!記得引入哦……

相關(guān)文章

最新評論