user should have to enter 4 numbers in textbox after 4 numbers textbox should not take any number
-
The TextBox has a "MaxLength" attribute. It does exactly what you want.
That won't quite do it. The OP said NUMBERS. Your solutions will only limit the length but still allow any character to be entered.
I know the language. I've read a book. - _Madmatt
-
That won't quite do it. The OP said NUMBERS. Your solutions will only limit the length but still allow any character to be entered.
I know the language. I've read a book. - _Madmatt
Ok then, I missed the "numbers" part of the question. But then this can easily be taken into account by adding a compare validator that checks for the type.
-
Ok then, I missed the "numbers" part of the question. But then this can easily be taken into account by adding a compare validator that checks for the type.
No, a compare validator works by comparing the value of one field to another. It, or any validator, also does not prevent characters from being entered when only numbers are expected. Validators check the input afterward, they don't prevent entry.
I know the language. I've read a book. - _Madmatt
-
i have a form in which i am entering country code and zip code. user should have to enter 4 numbers in country textbox after 4 numbers country textbox should not take any number. please reply..........
You can use the MaxLength attribute of the textbox to limit the lengh to 4 and use this function to limit the input to only numbers. If you want to restrict entry of invalid characters, you'll have to handle the keypress event and write appropriate code.
function isNumeric(str)
{
var i=0;
for(i=0;i '9')
return false;
}
return true;
} -
You can use the MaxLength attribute of the textbox to limit the lengh to 4 and use this function to limit the input to only numbers. If you want to restrict entry of invalid characters, you'll have to handle the keypress event and write appropriate code.
function isNumeric(str)
{
var i=0;
for(i=0;i '9')
return false;
}
return true;
}There are far better examples and implementations than this.
I know the language. I've read a book. - _Madmatt
-
There are far better examples and implementations than this.
I know the language. I've read a book. - _Madmatt
-
No, a compare validator works by comparing the value of one field to another. It, or any validator, also does not prevent characters from being entered when only numbers are expected. Validators check the input afterward, they don't prevent entry.
I know the language. I've read a book. - _Madmatt
Ok I agree on the second part. However, a compare validator can be used to check for data types
-
I understand, but for a starter, this should be okay. Moreover, by redirecting new users to pre-written frameworks and controls, we're actually discouraging them from learning the language itself.
Shameel wrote:
we're actually discouraging them from learning the language itself.
No. .NET is a pre-written framework, has it discouraged you from learning? JQuery is a framework, have you stopped learning JavaScript? Lazy coders may not want to learn any further than how to use an API but true developers will learn and better themselves. Expereinced developers also know to not recreate the wheel, if there is a perfectly good framework or control to do what is needed they will use it and save the time for more complex problems.
I know the language. I've read a book. - _Madmatt
-
Ok I agree on the second part. However, a compare validator can be used to check for data types
Once again, this is after the fact. It does not prevent entry. Thanks for playing.
I know the language. I've read a book. - _Madmatt
-
Once again, this is after the fact. It does not prevent entry. Thanks for playing.
I know the language. I've read a book. - _Madmatt
In which I said that you were right. What I was replying to was the first part of your statement "No, a compare validator works by comparing the value of one field to another"
-
Shameel wrote:
we're actually discouraging them from learning the language itself.
No. .NET is a pre-written framework, has it discouraged you from learning? JQuery is a framework, have you stopped learning JavaScript? Lazy coders may not want to learn any further than how to use an API but true developers will learn and better themselves. Expereinced developers also know to not recreate the wheel, if there is a perfectly good framework or control to do what is needed they will use it and save the time for more complex problems.
I know the language. I've read a book. - _Madmatt
Mark Nischalke wrote:
Expereinced developers also know to not recreate the wheel, if there is a perfectly good framework or control to do what is needed they will use it and save the time for more complex problems.
Correct. But the OP doesn't seem to be an experienced guy. So, let him learn the language first.
-
Mark Nischalke wrote:
Expereinced developers also know to not recreate the wheel, if there is a perfectly good framework or control to do what is needed they will use it and save the time for more complex problems.
Correct. But the OP doesn't seem to be an experienced guy. So, let him learn the language first.
Inexperienced will not take the time for in-depth learning. Most employers don't pay for training or to have their devs learn something, they want results.
I know the language. I've read a book. - _Madmatt