Hai, 我正在使用SmartGwt Java。要使用keyPressFilter格式化價格,請提出任何正則表達式。它只接受0-9和單個小數。 現在我正在使用KeyPress處理程序。如果它是空的(默認),則使用TextItem.setEmptyDisplayValue(「0.00」)將此值設置爲「0.00」。所以第一次它會接受單個小數點的事件,但是還有一個小數點(「0.00」)。爲這個問題提供解決方案。 在此先感謝。 Regards, Sathya。TextItem with Price Filter
0
A
回答
0
許多不同的解決方案都是可能的。
按任意鍵後將空白字段變爲「0.00」的內容是令人驚訝的,甚至可能令用戶感到不安;我不會那樣做。如果你要幫助他,你必須徹底完成,提供相當於一個輸入編輯器。否則,讓他做他的工作,並在他試圖將焦點轉移到現場時檢查最終結果。
正則表達式是檢查輸入的一種方法;但單獨完成,這是一個懶惰和無效的解決方案。每次擊鍵都可以訪問整個輸入文本。您可以通過在keyUp
時間檢查輸入文本中是否已經有小數點來解決您的問題,如果不是,則不允許另一個小數點。你可以做類似的事情,以防止在小數點後輸入2位以上的數字。
相關問題
- 1. -ms-filter with javascript
- 2. ssrs with visible filter
- 3. Filter BindingSource with entity framework
- 4. AngularJS ng-repeat with filter
- 5. angular-js ng -paginate with filter
- 6. map and filter with lodash 3.10.1
- 7. dd-collapse-text with emoji filter
- 8. DistinctCount for relatedtable with additional filter
- 9. Rxjs filter operator not working with Angular2 Observable
- 10. ng-filter with ng-repeat for objects(k,v)
- 11. angularjs ng-repeat with Filter或ng-if條件
- 12. magento price getPrice()value
- 13. Flex中擴展TextItem 4級
- 14. 如何在商品添加爲價格的「Price for price」產品
- 15. QuantLib OpenOffice/Excel YIELD/PRICE功能
- 16. jQuery的.Filter功能問題
- 17. beforequery with filter在IE6中無法正常工作extjs
- 18. Angularjs Ng-repeat with search filter only only on 2nd character keyup
- 19. angularjs ng-repeat with filter返回空數組第二次
- 20. Paper.js調整大小光柵/ TextItem /拖動
- 21. jQuery if if else else filter
- 22. Pivotfields multiple filter
- 23. DataTable Filter mystery
- 24. 「git filter-branch」中「--tree-filter」和「--index-filter」有什麼區別?
- 25. Filter ClientDataSet
- 26. Filter ObservableCollection
- 27. Filter DataTable
- 28. SimpleAdapter Filter
- 29. 在ASP.net中執行amout(price)的驗證
- 30. 正則表達式,用於驗證PRICE