How to determinate if a value is digital

A

ad

I want to determinate if a value in a Text is digital or character.
How can I determinate it with Javascript
 
G

Guest

You can use a regular expression for this. If you use the
RegularExpressionValidator control it will check it client side and server
side for you. If like me you find regular expresions somethign of a dark art
there is a good library of the here http://www.regexlib.com/
 
G

Guest

In javascript, You can use KeyPress Event also to find out the Char or digital.

For Example, (The following example will allow 0-9, a-z, A-Z, Underscore and
Dots in the UserName Text box in ASP.Net)

Place the following line in the Form_Load Function.

txtUserName.Attributes("onKeyPress") = "return chkUserNameKeyPress(event,'"
& txtUserName.ClientID & "')"

Place the following code in the Design form.

<script language=javascript>
function chkUserNameKeyPress(e,Id)
{
if(48 <= e.keyCode && 57 >= e.keyCode)
return true;
else if(97 <= e.keyCode && 122 >= e.keyCode)
return true;
else if(65 <= e.keyCode && 90 >= e.keyCode)
return true;
else if (e.keyCode == 46 || e.keyCode == 95 || e.keyCode ==
8)
return true;
else
return false;
}

I hope it will helps you.

with regards,
Murali
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top