How to check if entered value is hex or number?

Posted by Allemahesh under ASP.NET on 7/15/2013 | Points: 10 | Views : 2111 | Status : [Member] [MVP] | Replies : 4
I am entering the hex value in text box. Now I want to check if it is hex or not. Any help.




Responses

Posted by: Ssj_Kumar on: 7/15/2013 [Member] Starter | Points: 25

Up
0
Down
you can use Regex
or you can use isNaN function in javascript which retrun bool output
or
function Validate()
{
if (!(event.keyCode > 47 && event.keyCode < 58))
alert('Only Numbers allowed');
return event.returnValue = '';
}



Regards,
Jayakumar Selvakani

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

Posted by: Allemahesh on: 7/15/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
I want to check in c# code. I have post this question in asp.net category and not in JavaScript.

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

Posted by: aswinialuri-19361 on: 7/15/2013 [Member] Starter | Points: 25

Up
0
Down
hi,
refer this link it will help you
http://stackoverflow.com/questions/5126672/how-to-check-in-c-sharp-if-a-input-string-is-a-binary-hexa-number

Mark as Answer if it helps you
Thanks&Regards
Aswini Aluri

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

Posted by: Ssj_Kumar on: 7/15/2013 [Member] Starter | Points: 25

Up
0
Down
string Value = "100A";
int Number;
if (!int.TryParse(Value, out Number))
{
label1.Text = "String";
}
else
{
label1.Text = "INT";
}

Regards,
Jayakumar Selvakani

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

Login to post response