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

[Solved] How do I make cursor in the beginning of masked input during focus?

3 Answers 1123 Views
Input
This is a migrated thread and some comments may be shown as answers.
bemara57
Top achievements
Rank 1
bemara57 asked on 21 May 2008, 11:15 PM
I'm using a mask input that's 10 digits long. The annoyance is when I click in the box ready to type, it puts the cursor in the middle of the input (or whereever I click). How can I make it so that when I click in the input box, it starts the cursor at the beginning like it does with the text input (only when it's empty).

3 Answers, 1 is accepted

Sort by
0
Baatezu
Top achievements
Rank 2
answered on 22 May 2008, 01:40 AM
I've never done this before, so it's just what I'd try first:

Make a function for the OnFocus of the testbox.
<telerik:RadTextBox ID="RadTextBox1"  runat="server"
    <ClientEvents OnFocus="Focus" /> 
</telerik:RadTextBox> 

Then make the javascript function that uses the client programming to set the caret position.
<script type="text/javascript"
 function Focus(sender, eventArgs) 
 { 
   sender.set_caretPosition(0); 
 } 
</script> 


That's what I'd try first.
0
Accepted
Konstantin Petkov
Telerik team
answered on 22 May 2008, 06:00 AM
Hello bemara57,

Have you also tried the SelectionOnFocus property of the RadInput control? You will find an example below:

http://www.telerik.com/DEMOS/ASPNET/Prometheus/Input/Examples/RadTextBox/Settings/DefaultCS.aspx

Greetings,
Konstantin Petkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
bemara57
Top achievements
Rank 1
answered on 22 May 2008, 03:00 PM
That's perfect! Thanks for all the help!
Tags
Input
Asked by
bemara57
Top achievements
Rank 1
Answers by
Baatezu
Top achievements
Rank 2
Konstantin Petkov
Telerik team
bemara57
Top achievements
Rank 1
Share this question
or