473,396 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Q: only number in a textbox

Hello,
I am trying to allow only number in a textbox. I need to put it into
database as double. So Convert.ToDouble should not fail. How should I do this?
Thanks,
Jim.

Nov 19 '05 #1
8 1496
I would add a Regular Expression validator control and then write (or find)
some regex that would validate a double)

-Cliff

"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com...
Hello,
I am trying to allow only number in a textbox. I need to put it into
database as double. So Convert.ToDouble should not fail. How should I do this? Thanks,
Jim.

Nov 19 '05 #2
I would add a Regular Expression validator control and then write (or find)
some regex that would validate a double)

-Cliff

"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com...
Hello,
I am trying to allow only number in a textbox. I need to put it into
database as double. So Convert.ToDouble should not fail. How should I do this? Thanks,
Jim.

Nov 19 '05 #3
Use validation, and make sure that the value in the field is numeric. Any
numeric value can be converted to a double.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com...
Hello,
I am trying to allow only number in a textbox. I need to put it into
database as double. So Convert.ToDouble should not fail. How should I do
this?
Thanks,
Jim.

Nov 19 '05 #4
Use validation, and make sure that the value in the field is numeric. Any
numeric value can be converted to a double.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com...
Hello,
I am trying to allow only number in a textbox. I need to put it into
database as double. So Convert.ToDouble should not fail. How should I do
this?
Thanks,
Jim.

Nov 19 '05 #5
Just create a CompareValidation control set the type to Double and the
Operator to DataTypeCheck

<asp:CompareValidator id="CompareValidator1" runat="server"
ErrorMessage="CompareValidator" Type="Double"
Operator="DataTypeCheck"></asp:CompareValidator>

"JIM.H." wrote:
Hello,
I am trying to allow only number in a textbox. I need to put it into
database as double. So Convert.ToDouble should not fail. How should I do this?
Thanks,
Jim.

Nov 19 '05 #6
Just create a CompareValidation control set the type to Double and the
Operator to DataTypeCheck

<asp:CompareValidator id="CompareValidator1" runat="server"
ErrorMessage="CompareValidator" Type="Double"
Operator="DataTypeCheck"></asp:CompareValidator>

"JIM.H." wrote:
Hello,
I am trying to allow only number in a textbox. I need to put it into
database as double. So Convert.ToDouble should not fail. How should I do this?
Thanks,
Jim.

Nov 19 '05 #7
This article shows how to use javascript to limit numeric entry only in a
textbox:
http://SteveOrr.net/articles/InheritAndExtend.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com...
Hello,
I am trying to allow only number in a textbox. I need to put it into
database as double. So Convert.ToDouble should not fail. How should I do
this?
Thanks,
Jim.

Nov 19 '05 #8
This article shows how to use javascript to limit numeric entry only in a
textbox:
http://SteveOrr.net/articles/InheritAndExtend.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com...
Hello,
I am trying to allow only number in a textbox. I need to put it into
database as double. So Convert.ToDouble should not fail. How should I do
this?
Thanks,
Jim.

Nov 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John S | last post by:
I have created an event handler that is trying to format each number as it is typed. Example If the first char is 1 = output is $1.00 second char is 3 = output is $13.00 next is 5 = $135.00...
3
by: Homer Simpson | last post by:
How do I convert a value in a textbox to a real number so I can perform some math ops on it? I understand I will need to validate the textbox's input to make sure it is a real number and not a...
3
by: Hai Nguyen | last post by:
Hi All I have a textbox want to mask as phone box. How can I do it? Thanks
6
by: JIM.H. | last post by:
How can I grantee that user enter only number in the textbox. If possible accept ","and "." in the number. Can I do this?
6
by: Scott Kilbourn | last post by:
Hi, I'm writing a control that inherits from TextBox. I need to adjust the width of this control based on the number of characters in the control. I'm having a hard time with this. The...
4
by: BLACKDOG157 | last post by:
I have to make a form with a variable number of textboxes. If, in the previous screen, the user chose a 2 day hotel stay, I need to input the number of rooms for 2 days. But if in the previous...
1
by: Wayne | last post by:
There is probably a simple solution to this but: I have a textbox that is bound to a number field in a table. The field type is "double". If I enter a negative value directly into the table it...
4
by: Usmaak | last post by:
Hi, I have a TextBox that is set to a certain width. From this, I need to figure out the max number of characters that can fit into the TextBox. I'm using Courier New font, size 8.25. I've...
5
by: rn5a | last post by:
A Web Form has a TextBox within a DataGrid wherein users are expected to enter only whole numbers. It should be validated so that the TextBox doesn't remain blank or any non-numeric data is...
4
by: darith | last post by:
Hi all, I want to know code in vb.net to get number of selected text in MS Word. how can we write? Please help me. I need it urgent. in textbox we just write textbox.selectedtext so we can get...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.