Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with checking blank textboxes

Status
Not open for further replies.

supervi

MIS
Mar 22, 2003
61
0
0
CA
hello, I'm a junior coder having trouble with what the subject state.

Currently, I'm working on a c# project. I have a form where the user enters in a credit card number and a purchase amount. I have a created a web service so once the information is entered, the credit card number searches through my table to find the credit limit. If the purchase amount exceeds the credit limit, then it would return "not enough credit" and vice versa.

Anyways, I'm having trouble with handling if the textbox is blank. Should I be building the web service to handle empty values or should it be at the form level? Also, how would I be checking it?

I've tried:
- credit.equals(null)
- credit.equals("")
- credit.ToString().length == 0

and none of them seem to help.

Thanks in advance for any help
 
To check for a blank string, you may want to use credit.Trim().Length > 0 which will return true if there was something entered.

In your code, credit.ToString makes me think that you are dealing with a numeric data type. Has the credit variable already been converted to a numeric type or is it still a string?

If its a numeric type, it is likely that your blank string has been converted to "0" someplace which is why all of your criteria are failing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top