This is a migrated thread and some comments may be shown as answers.

add zero in numerictextbox field

1 Answer 59 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Baris
Top achievements
Rank 1
Baris asked on 27 Feb 2014, 02:56 PM
I have numeric text box like that

    <telerik:radnumerictextbox showspinbuttons="true" incrementsettings-interceptarrowkeys="true" incrementsettings-interceptmousewheel="true" labelwidth="120px" runat="server" id="ddStartHour" width="100px" MaxLength="2" MaxValue="12" Value="0" MinValue="0" CssClass="app-input" DataType="System.Integer" >
    
        <NumberFormat  DecimalDigits="0" />
                                        
    </telerik:radnumerictextbox>

Now my numbers can be 0,1,2,3,4,5,6,7,8,9,10,11,12.

 But I want to add zero before the numbers which number is less than 10. SO I want to show my numbers like 00,01,02,03,04,05,06,07,08,09,10,11,12.

 How can I do that?

THX.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 28 Feb 2014, 07:07 AM
Hi Baris,

Please try the following sample code snippet to achieve your scenario.

ASPX:
<telerik:RadNumericTextBox ShowSpinButtons="true" IncrementSettings-InterceptArrowKeys="true"
    IncrementSettings-InterceptMouseWheel="true" LabelWidth="120px" runat="server"
    ClientEvents-OnValueChanging="OnValueChanging" ID="ddStartHour" Width="100px"
    MaxLength="2" MaxValue="12" Value="0" MinValue="0" CssClass="app-input"                             DataType="System.Integer">
    <NumberFormat DecimalDigits="0" PositivePattern="0n" />
</telerik:RadNumericTextBox>

JavaScript:
<script type="text/javascript">
    function OnValueChanging(sender, args) {
        if (args.get_newValue() > 09) {
            sender.get_numberFormat().PositivePattern = "n";
        }
        if (args.get_newValue() < 10)
            sender.get_numberFormat().PositivePattern = "0n";
    }
</script>

Thanks,
Shinu.
Tags
General Discussions
Asked by
Baris
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or