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

RadNumericTextBox on text Change...

1 Answer 138 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Amit
Top achievements
Rank 1
Amit asked on 28 Oct 2010, 07:16 AM
Hey everyone,

I have a radNumericTextBox inside grid's insert form,I have added a onBlur function to fill a label on lose focus on text box.Now,i want to change this event to onTextChange.Which event should i change.I tried OnValueChanged,but it does'nt work also its specified that this event is fired just after the textbox loses focus.I want the value of label to change when textbox is in focus and when user changes text.How is this possible?..

* Also,what property should i use to clear the past entries from textboxes like radmaskedtextbox,radNumericTextBox?..
* 1 more thing,in my numeric text box,when a -ive entry is written it selects the minimum value.How can i avoid -IVE KEYPRESS?...
*  Also,i've a radmasked textbox that i've masked for 10 numeric digits "##########" like this its working fine,except for that it does'nt        take  space which is good but user can give spaces by pressing left or right keys,how to disable that?....

Thanks
Amit

1 Answer, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 02 Nov 2010, 01:07 PM
Hi Amit,

To achieve the desired functionality you could try handling the OnKeyPress event and use the following code snippet:
function OnKeyPress(sender, eventArgs)
{
    var textBoxElement = sender._textBoxElement;
    if(textBoxElement.selectionEnd == textBoxElement.selectionStart)
    {
       if(textBoxElement.textLength == textBoxElement.selectionEnd)
       {
            $get("messageDiv").innerHTML = sender.get_value() + eventArgs.get_keyCharacter();
       }
       else
       {
           var startIndex = textBoxElement.selectionStart;
           var startStr =  sender.get_value().toString().substr(0,startIndex);
           var endStr = sender.get_value().toString().substr(startIndex,sender.get_value().toString().length - startIndex);
           $get("messageDiv").innerHTML = startStr + eventArgs.get_keyCharacter() + endStr;
       }
    }
  }

Additionally I am sending you a simple example which demonstrates the desired functionality.

Regarding your other questions:
You could prevent entering symbols by handling the OnKeyPress event and call eventArgs.set_cancel(true) function. Please give it try and let me know if it helps you.


All the best,
Radoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Amit
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Share this question
or