EasyUI Forum
December 06, 2023, 07:23:59 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
   Home   Help Search Login Register  
Pages: [1]
Author Topic: Filter function on numberbox  (Read 472 times)
Posts: 39

View Profile
« on: March 19, 2023, 07:43:01 AM »

Please refer to this discussion in which I asked how to disable the decimal point in a numberbox.

I just discovered that on numberboxes where I use the code you provided, the getValue method no longer works when the value is changed.. Even after the change, getValue still returns the old value. I have to use getText instead.

Can you explain the difference between getValue and getText for numberboxes? They always seem to return the same thing so I don't understand why getValue even exists.

Hero Member
Posts: 2244

View Profile Email
« Reply #1 on: March 20, 2023, 07:03:45 PM »

Please look at this example. The 'getValue' method works fine.
<!DOCTYPE html>

<meta charset="UTF-8">
<title>Basic NumberBox - jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/icon.css">
<script type="text/javascript" src="https://www.jeasyui.com/easyui/jquery.min.js"></script>
<script type="text/javascript" src="https://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
$(function () {
precision: 0,
filter: function (e) {
if (String.fromCharCode(e.which) == '.') {
return false;
} else {
return $.fn.numberbox.defaults.filter.call(this, e);

<input id="nb" label="NumberBox1:" labelPosition="top">
<button class="easyui-linkbutton" onclick="alert($('#nb').numberbox('getValue'))">GetValue</button>


The 'getValue' method returns the value while the 'getText' method returns the displaying text. They are different in some conditions. For example, if you set the 'prefix' property or some other formats, the 'getText' method will return the formatted text that looks like '$23.24', but the 'getValue' method only returns the '23.24' value according to the 'precision' setting.
Pages: [1]
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!