How to Validate the textbox using Ascii values?

Posted by Sapna under VB.NET on 12/27/2009 | Views : 15037 | Status : [Member] | Replies : 2
I have 3 text boxes and 1 Listview.
I want it to work like,
When i press enter the control from Textbox1 should pass to Textbox2,from Textbox2 to Textbox3 and now when i press "Enter" the values of all 3 textboxes should get passed to listview.
PLEASE HELP IT'S URGENT.......




Responses

Posted by: Virendradugar on: 12/28/2009 [Member] [MVP] Silver

Up
0
Down
Hi Sapna,

Onkeypress event of the textbox, you need to check the keycode. If it is of enter key then pass focus to next control.

See Demo:

 <asp:TextBox ID="TextBox1" runat="server" onkeypress="CheckValue();"></asp:TextBox>



Here is JavaScript function.

<script type="text/javascript" language="javascript">

function CheckValue()

{

if(event.keyCode == 13)
document.getElementById('<%=TextBox2.ClientID %>').focus();
}
}


Hope this helps.

Thank you for posting @ DotNetFunda.

Thanks,
Virendra Dugar

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

Posted by: Sagarp on: 1/2/2010 [Member] Bronze

Up
0
Down
You can do this in the Key_Press event of that particular TextBox in which you want to enters only the a-z.



Use this code in the keypress event



int ascii = Convert.ToInt16(e.KeyChar);



if ((ascii >= 97 && ascii <= 122) || (ascii == 8))

{

e.Handled = false;


}

else

{

e.Handled = true;


}



Ascii values of "a" to "z" is 97 to 122. And 8 is ascii vaue of Backspace is used to delete the characters using backspace

Thanks
SagarP
http://www.emanonsolutions.net
http://emanonsolutions.blogspot.com/

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

Login to post response