PDA

View Full Version : [CLOSED] NumberField only with positive values



RCN
Jul 09, 2013, 6:37 PM
Hi all,

When the minus key is pressed, the minus character appears, but when the minus key is pressed more than once, in any position of the NumberField, the minus character appears more than once. In my opinion, the minus character should appear only if the key is pressed in the first position of the text.

And if I set the MinValue to a number greater or equal than 0, there is a way to not show the minus character?


<ext:NumberField ID="NumberField2" runat="server" FieldLabel="Test" MinValue="1"
MaxValue="100" AllowDecimals="false" Step="1" />

I already try using regex and MaskRe, but it's unsuccessfully.

Baidaly
Jul 09, 2013, 11:58 PM
Hello!

Try to use allowExponential config value:



<ext:NumberField ID="NumberField2" runat="server" FieldLabel="Test" MinValue="1"
MaxValue="100" AllowDecimals="false" Step="1">
<CustomConfig>
<ext:ConfigItem Name="allowExponential" Value="false" Mode="Raw" />
</CustomConfig>
</ext:NumberField>

RCN
Jul 10, 2013, 1:07 PM
Baidaly, the solution provided by you works as expected but the need of use a config called allowExponential is a litttle confusing, since the number typed is not exponential.

i would rather do the following than use allowExponential config:



<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<script type="text/javascript">
var validateKeyDown = function (field, e) {
if (event.keyCode == e.NUM_MINUS || event.keyCode == e.NUM_PLUS) {
e.stopEvent();
}
}
</script>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:NumberField ID="NumberField2" runat="server" FieldLabel="Test" MinValue="1"
MaxValue="100" Step="1" EnableKeyEvents="true">
<Listeners>
<KeyDown Fn="validateKeyDown" />
</Listeners>
</ext:NumberField>
</body>
</html>

Baidaly
Jul 10, 2013, 11:57 PM
Thank you for your solution!

We are closing this thread. If you will have any problems or concerns we will reopen it.

RCN
Jul 11, 2013, 4:00 AM
Thank you Baidaly