Click here to Skip to main content
15,901,853 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi ,
in my application i have text box which is accepting only 11 digit numeric values.
my problem is that if someone is input all 0 value it is accepting ,which i don't want.how can i restrict it.
thanks
Posted
Comments
[no name] 9-Apr-14 7:35am    
Well you would check it and see if the user entered all zeros.
ZurdoDev 9-Apr-14 8:13am    
There is no magic code to do this. You just have to write the code. Where are you stuck?
Peter Leow 9-Apr-14 21:27pm    
There are too many questions to your question. You tagged your question as c#, but asked about vb.net, not clear if it is a web app or win app. How do you expect to get help with such confusing message.
It is totally out of question.

Use compare field validator for client side validation


VB
<asp:CompareValidator runat="server"
        id="cmpNumbers"
        controltovalidate="txtNumber"
        ValueToCompare="000000000"
        operator="MoreThan"
        type="Integer"
        errormessage="Invalid Number" />
 
Share this answer
 
Comments
ruby kaur 11-Apr-14 1:45am    
hi i use comparevalidator like this:
<asp:CompareValidator runat="server" id="cmpNumbers" controltovalidate="txtTIN"
ValueToCompare="000000000" operator="GreaterThan" type="Integer" errormessage="Invalid Tin Number" />

but it shows error msg in both condition weather i enter 00000000000 or 12345678912 why so.
and i am checking foe 11 digit no. and you suggest value to compare only 9 digit 000000000.
pls explain, and help.
Just add check like (in javascript)

JavaScript
if(parseInt(textboxvalue) == 0)
{
alert('All Zero entered');
}
 
Share this answer
 
Comments
ruby kaur 9-Apr-14 7:55am    
where to put this check.
ZurdoDev 9-Apr-14 8:14am    
It may not be ASP.Net. It wasn't tagged that way at least.
In textcahnged event put this:
if(textbox.Text.Lenth==11 & int.parse(textbox.Text)==0)
   textbox.Text.clear();
 
Share this answer
 
if i can get your question correctly, the solution should be following,

int count= 0;

for(int i = 0; i<input.length;>{
if(input.Equals("0"))
{
count++;
}
}

if(count == 11)
{
//do your validation here
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900