commafy

這個是我在ext.net用到的

但應該跟javascript差不了多少

Ex:

<Change Handler="this.setValue(commafy(this.getValue()));">
</Change>

 

此範例目的是用於將欄位設定為只能輸入數字,且三位一撇","

 

在javascript中 == 及 ===

=== 不但判斷大小及內容 還會連帶物件屬性 一併判斷

ex:

 window.onload = function ()
    {
        var s1 = "111";
        if (s1 === 111)
            alert("s1 = 111");
        else
            alert("s1 != 111");
        if (s1 == 111)
            alert("Yes");
        else
            alert("No");
        var b1 = true;         if(b1 === "true")         alert("b1 === 'true' ");         else         alert("b1 != 'true' ");     }

s1 是字串 "111" 所以如果跟 111 數字做比較 使用=== 則會判斷本身屬性是否相符

則會跳("s1 != 111")  

而若 s1 == 111  由於不會去比較本身屬性

則會得到 true 印出 alert("Yes")

順道一題 如果變數是null 、"" 或 '' 一樣可以判斷

Ex:

var booltest = null;
            if (booltest)
                alert("true");
            else
                alert("false");

null 、'' 和 ""  都回傳false 有值則回傳true

 

 

 

 

未完待新增......

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 JoshS 的頭像
    JoshS

    JoshS的部落格

    JoshS 發表在 痞客邦 留言(0) 人氣()