Only numbers can enter into that Textbox
We can use Regular expression validator for this:
In the validation expression property keep ^\d+$.
<asp:TextBox ID="TextBox1" runat="server" Style="z-index: 100; left: 259px; position: absolute;
top: 283px" ValidationGroup="check"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox1"
ErrorMessage="Please Enter Only Numbers" Style="z-index: 101; left: 424px; position: absolute;
top: 285px" ValidationExpression="^\d+$" ValidationGroup="check"></asp:RegularExpressionValidator>
Thank You. This helped me in my project. Thanks a lot.
This is great!! It helped me so much..
Thank you
Thanks for you this solve my problems
Thanks you ,it help me alot
Thanks for this, just what I was looking for.
Its a good solution, the best practice is use a parseint or similar and js validator.
good.
Tks !! It helps me
boka ,chaupat,
Ya…!!! its really great… help’s me lot… thank u much….
It’s great… it save a lot of code 🙂
Thanks so much
use ^\d*\.?\d*$
Thanks,
it is simple and good
Thanks … it is very simple
very goood
Hi bharath RadheKrishna,
thanks a lot. I found this option before anything and it just worked fine for me 🙂
Thanks a lot!!!
good one
simply superb…thanks a lot
in .net 2.0 validationexpression is not a valid attribute in properties
Hey Rajesh, I would like to know the validation in classic asp or .net 2.0
gracias, me fue de mucha utilidad
Muchas gracias, continúe con tan buen trabajo!
emm.. funny.
Hiya this worked great for me, however I would also like to allow spaces in between the numbes eg for a phone number
01485 222222
^\d*\ \d*$
This will take care of only number and will also allow spaces i believe. just make sure there is a space in between centered back slashes
Thank you a lot, that really helped
good .. work…. bro..
Thank you!
Thanks!
Thank you for such a good post. It made me finish my project pretty soon than expected.
we can use also use ^\d*\.?\d*$ expression
Thanks too, but yours (sandesh k) worked better for me, can accommodate real numbers.
Thanks too..cool
Urs more flexible as can play with decimal. But thx everyone too!
Thank you, It is very usefull for me
This is great help, thanks
Thanks a lot !!
Thanks for the quick help. Might I also suggest the following for values that may can be empty or may have a decimal point: ^\d*([.]\d*)?|[.]\d+$
Thank You.. Its Really Great.. You My Problems.. Once Agaun Thank You…
Very nice 🙂 thanks.
only number and space
???
Thanks a lot.
This code survived me from a bundle of non required coding.
thank you for help my problem
very good code. simple and short
Truthful words, some authentic words man. You made my day.
bakwas
+1 thanx
Thanks a loat! its working….. It solve the my prob.
Thank alot! your code is very good for me
Thanks!
Tnx
thank u sooooo much..may god bless you…it helped me in my final year project.. thanxx aloot…. 🙂
How can I change it to accept also a comma?
Luigi
/^d*[0-9]*(|.\d*[0-9]|,\d*[0-9])?$/ use this expression
very helpful
simply super
Thx to much,
muchas gracias
🙂
thanks
Simply Great post…
thanks dear………
thnx it helped……….
Your code to enter only digits in a textbox did’nt work for me in the regularvalidation expression.please help me out!!.
thank you so much.
helpfull
Thanks, this is just what I was looking for. Great post!
ffff
Thank you for your valuable data
nice….it helped to me…
Great post!
Hi It helped me 2 But it would be very gr8 if u could tell me wat does “$ n ^” stands for.
Thanks in Advance
Hi Pradnya,
Try this: http://www.regular-expressions.info/quickstart.html
^ = start of expression
$ = end of expression.
correct me if Im wrong.
Simple thing but very useful. Thanks for the info
how to validate textbox with only ten digits for cell number in vb.net if u know send code to me & also in mdi form if child form1 is in active,then we can also again open child form1 as my requirements i cant open that child form1 if its in active/open. please send code to me..
please send code to me as quickly as possible… my mail id is kumari_zeal@yahoo.com
that code is very useful in my project
thanks sir it’s very helpful for int value
thanks regards
Avdhesh kumar
thanks. 🙂
it is very useful in my project.. Thanks
Great……………………………………
incomplete, validation allows blank/null values…
Thanks a Tonn!!!!!!!!!!!!!!!
Thanks Nice Job Done by
very very Good, thanks man
Thanks Dear.
Thanks Yaar,
It will help me in my project.
Bye Bye
Its a nice code Bharat, Tks dude….
hi thnx but now problem is only enter float value
I would like to highlight the textbox in red (some color) if the validation expression is not correct
nice..easy to use..
thanks…
It will help me in my project.
How can I accept format with : (xxx)-xxx-xxxx . User should be able to just input numbers but the input should get filled as (xxx)-xxx-xxxx
omg u save my ass ^^
quite helpful
thanks
i have written a similar post:
http://codeshode.blogspot.com/2010/07/validatingmasking-numbers-in-textbox.html
Thank You Very Much…Helped me a lot..its really quick reference..
Thanks this helped me!
thank you, you helped me!
Hey i need textbox to accept numeric values but greater than zero….can anyone help me with this….Please its urgent
Thanks
thanks a lot
Thank you a lot it helped me so much
🙂
I want t display only characters (A-Z) in the Textbox if you have the code pass me on thanks ………….!!!!!!!!!!!!!
hello sai, you can Use this regular expression [A-Za-z] for only alphabets in a text box.
it is not accepting for the space bar
try this
^[A-Za-z ]+$
thank u this helped me
thanx dude…..
it is good….
Thanks..
it’s work…
In my application i am using two grids,when the user clicks on the first grid the data should be displayed on the second grid,how to populate the data,help me to solve this problem…!!!!!!!!!!!!!!
You can populate use dataset copy and assign the dataset used in first grid to second grid For more info: http://msdn.microsoft.com/en-us/library/system.data.dataset.copy.aspx
Hello Sir,
In the second grid in which i want to display data i am using text box which are created by item template i am new to programming i dont have any idea if you have any coding in connection please forward me the link…..!!!!!!!!!!!!!!
Thanks alot it helped me also
it’s too good and very easy ..it helped me
Thanks a lot. This helped me to solve numbers only validation. 🙂
thanks, it works.
good it work fine
and if want to validate both integer and empty field
copy below code……
*
Thank you, it helped me.
Thanks, helped me
It’s very useful.. Thanks..
I believe that this will only work for required fields. Have you tried typing a single space into a non-required field using this expression?
thnx a lot god bless u
what a searching for only enter number purpose
perfect yar ….
Thanks man, you saved my time
thanks Sir It Helps in my Project.
PROJECT : ONLINE EMPLOYEE MANAGEMENT SYSTEM
COMPANY : h3-Technologies
WEBSITE : http://www.h3-technologies.com
Thanks a lot, this is really helpful and you really save my time.
Thank you again 🙂
Worked….. thanks
what expression should be used only allow numbers and dot(.)?
Thank u.
what do for only enter a string in a textbox in asp.net using c#
cool
thanks if helped me dude
thanks
How can i include ‘+’ sign also into this textbox
Validation Expression(Email ID(IT will also accept ‘+’sign into the textbox))=^(?(“”)(“”.+?””@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&’\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$
thanks a lot………
thanks
Thanks alot.
Thanks a lot… It really helps me
(046) 876-4521
what formula should I use so that the validator can determine only this kind of phone number?? tnx. 🙂
@shaniboy telll me the syntax, so i can help u
syntax means – phone number of which country u want like all this stuuffs..
good man ,keep it up…
philippine’s phone numbers..tnx. 🙂
Batane k liye Sorry
waah g sir,thanx
it helps me
This greate and useful thank you so much its awesome solution its help me i, always use it thanks….
thanq
Thanks divya
Super….
Thanks
Hi there would you mind stating which blog platform you’re working with? I’m
looking to start my own blog in the near future but I’m having a hard time selecting between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design seems different then most blogs and I’m looking for something
completely unique. P.S My apologies for being off-topic but
I had to ask!
Go for wordpress
Everything is very open with a precise clarification of the issues.
It was definitely informative. Your site is very helpful.
Thanks for sharing!
very usefull tips
This regular expression accept the “#,&,*,%,$” these Special Characters
so please tell me which regular expression is correct
it is not working
Thanks a lot
THANKS A MILLION 🙂
you may have an important weblog here! would you prefer to make some invite posts on my blog? cegkedeedgge
Nice validation…thanks
thanks
Роst writing is also a fun, if you be familiar
with aftᥱr that you can write іf not it is difficult to
write.
Hey, on occasion I get a 503 site message when I arrive at your page. Just a heads up, cheers
I will be inside of metropolis Saturday and puzzled where by the simplest location was in direction of observe the sport inside previous metropolis
Hi
I need a regular expression to validate the user only can write numbers between 1 – 5 and only 1 digit (For Example: 1, 2, 3 but not 10,22,34)
Stared different contract:
http://bette.web1.telrock.net
Me sera de gran utilidad.