Validation Expression for Increment Value on RadNumericTextBox

3 posts, 0 answers
  1. Thomas
    Thomas  avatar
    2 posts
    Member since:
    Oct 2010

    Posted 18 Oct 2012 Link to this post

    Hi,
    I found the example below that shows how to force the user to enter a number in .5 increments. I need my radnumerictextbox to increment on pack size increments that will vary by item. So in my RadGrid I plan on setting the ValidationExpression on each item during itemdatabind. The bottom line is if the pack size is 24 the box should increment by 24 when the up or down key is hit but also only allow them to type valid increments 24,48,72 etc.
    Any idea what the ValidationEpression might look like or is there another way to read the increment setting on the control and only allowing valid increments to get entered? 

    <Telerik:RadNumericTextBox ID="txtQtyShp" runat="server" DataType="System.Int" DbValue='<%# Bind("qtyshp") %>'></telerik:RadNumericTextBox>

    <asp:RegularExpressionValidator ID="vldQtyShp" runat="server" Display="Dynamic"

    ErrorMessage="Please enter valid number." ValidationExpression="^\d+(\.[5])?$"

    ControlToValidate="txtQtyShp">

    </asp:RegularExpressionValidator>

    Thanks,
    Tom Usselman

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    ErrorMessage="Please enter valid number." ValidationExpression="^\d+(\.[5])?$"

     

    ControlToValidate="txtQtyShp">

     

    </asp:RegularExpressionValidator>

  2. Jayesh Goyani
    Jayesh Goyani avatar
    2733 posts
    Member since:
    May 2010

    Posted 18 Oct 2012 Link to this post

    Hello,

    <telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server" MinValue="24" IncrementSettings-Step="24" ShowSpinButtons="true">
               <ClientEvents OnValueChanging="ValueChanging" />
           </telerik:RadNumericTextBox>
    function ValueChanging(sender, args) {
                   if (args.get_newValue() % 24 != 0) {
                       args.set_cancel(true);
                   }


    Thanks,
    Jayesh Goyani
  3. Jeroen
    Jeroen avatar
    1 posts
    Member since:
    Aug 2013

    Posted 07 Aug 2013 Link to this post

    I'm using a RadListView with an RadNumericTextBox for each item.
    Every item can have a different IncrementStep, and I needed validation without a hardcoded IncrementStep.
    I want to share my code for others with the same requirement:

    function numericValueChanging(sender, args) {
        /*extra properties are stored as json value in hidden input*/
        var id = sender._clientStateFieldID;
        var jsonval = $('#' + id).val();
        var jsonobj = $.parseJSON(jsonval);
        /*Because I don't see the incrementstep, I take the minValue*/
        var increment = jsonobj.minValue;
        if (args.get_newValue() % increment != 0) {
            args.set_cancel(true);
        }
    }

     

     

     

     

Back to Top