Asp.net Textbox Editing Problem due to the following Javascript

Posted by Vuyiswamb under JavaScript on 11/22/2010 | Points: 10 | Views : 1819 | Status : [Member] [MVP] [Administrator] | Replies : 2
It is that time of the day. hungry i cant cope anymore

I have a Javascript attached here http://www.rbcprojects.co.za/JS.html
and i am setting the max length of the text on the server side. Now this is working , the main purpose of this javascript is that when the user types till the "MaxLength" of the textbox. Now this works fine, when the value of the maxlength is 3 , if a user tries to type the 4th text, it will set the focus to the next textbox.

Now my problem is that now , let us say one made a mistake in textbox 3 and want to go and edit, immidiately when you edit the text in the textbox 3 , the focus jumps quickly to textbox1 before the editing is finished. Below is the event that is used

     <asp:TextBox ID="txtUnitLen1"  onKeyUp="Jump()"    runat="server" 
></asp:TextBox>


I just need to go and eat, i will look at your reply tomorow.

thanks again for your help
Thanks

Thank you for posting at Dotnetfunda
[Administrator]



Responses

Posted by: T.saravanan on: 11/23/2010 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi Vuyiswamb,

The Problem is in your JavaScript.In your script finally check the condition for

if (txtUnitLen20.length >= ddlAutoText) { document.getElementById("<%= txtUnitLen1.ClientID %>").focus(); } }


So the condition satisfy then only textbox1 will be focus.Because you check if condition in all textbox controls.

My suggestion is just pass your textbox ID in your script and then check that textbox have 3 character means focus the next textbox.

Cheers :)



Thanks,
T.Saravanan

Vuyiswamb, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 11/23/2010 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
Good Morning T.saravanan

Thank you for your reply.

I must mention that the problem is not when you have reached the last textbox in texbox20, but the problem can occur even if you have filled 3 textboxes and want to go the edit the previous textbox and it jumps unrully. And one thing that i have noticed again this morning, is that if i enter a text "123" it converts it to "321"

Thanks


Thank you for posting at Dotnetfunda
[Administrator]

Vuyiswamb, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response