[CLOSED] NumberField only with positive values

  1. #1

    [CLOSED] NumberField only with positive values

    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.
    Last edited by Baidaly; Jul 10, 2013 at 10:57 PM. Reason: [CLOSED]
  2. #2
    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>
  3. #3
    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>
  4. #4
    Thank you for your solution!

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

Similar Threads

  1. Replies: 10
    Last Post: Sep 20, 2017, 2:31 AM
  2. [CLOSED] Preventing NumberField from setting values to 0/MinValue/MaxValue
    By ingo.bleile in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Feb 13, 2013, 10:16 AM
  3. NumberField's Value Bug?
    By zxd9915 in forum 1.x Help
    Replies: 4
    Last Post: Mar 20, 2012, 5:44 AM
  4. [FIXED] NumberField and double values
    By Timur.Akhmerov in forum Bugs
    Replies: 1
    Last Post: May 04, 2010, 11:14 AM
  5. [CLOSED] usMoney turns negative numbers into positive
    By harafeh in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Feb 16, 2010, 7:25 PM

Tags for this Thread

Posting Permissions