2014-03-06 24 views

回答

1

嘗試將約束上的參數是這樣的:

var myNumberBox = new dijit.form.NumberTextBox({ 
    constraints: { pattern: "0.####" }, // The pattern that the number will be displayed or set as 
    value: "",  // The starting value if a value isn't set from any other source 
    required: false, // You may want to set this to true if user input is required 
    placeHolder: "(blank)" // What is shown when no value is present 
}); 

每當你得到的數字框的值,你可能想通過parseInt函數(值)或parseFloat(值)率先通過了它。另外檢查它是否是一個數字。

var value = parseFloat(myNumberBox.get("value")); 
if (isNan(value)) { 
    // Code to handle if it is NaN 
} 

如需更多幫助,請訪問link

我希望這會有所幫助。

相關問題