Hi,
I use the following code to archive a "numeric-only" input:
-----------------------------------------------------------------
<code>
// Check for "numeric-only" inputs
var _check = function(s)
{
var nums = s.match( /\d+/g );
if (nums) {
return nums.join("");
}
return "";
};
// A "numeric-only" input field
var element = qx.ui.form.TextField;
element.addEventListener("input", function(e) {
var value = this.getComputedValue();
var clean = _check(value);
if (value != clean)
{
this.setValue(null); // without this, the new value is not accepted :(
this.setValue(clean);
}
}, element);
</code>
-----------------------------------------------------------------
Maybe there's a better way, but it works quite well for my purposes.
/Kuddel
> Hi,
>
> I am trying to block the user entering non-number data on a number field.
>
> var yearsField = new qx.ui.form.TextField();
> yearsField .setLiveUpdate(true);
> var validator_int = qx.ui.form.TextField.createRegExpValidator(new
> RegExp('^(0|[1-9][0-9]*)$'));
> yearsField .setValidator(validator_int);
> yearsField .addEventListener("keyup", function(evt) {
>
> //What should I put here so when the user types junk characters let's say
> 'A', we don't want to let it go the Text Filed value. We want to disable
> that
> ?????
>
> });
>
> Some farms don't let you type bad data at all. They let you type numbers
> only. I don't want to give a second chance to validate it and alert the user
> that the data is bad. I want to stop upfont.
>
> How can I achieve it using Qooxdoo?
>
> Thanks.
> Kanugula.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel