473,320 Members | 1,841 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,320 software developers and data experts.

Validating two textbox controls

Im trying to do a function to validation two textbox controls. I want the
user to enter in text to either txtSurname or txtCompanyName but not both. Is
my logic wrong and if so can someone help me change this to achieve my goal.
Im really terrible at this and am under pressure to get it done so any help
at all would be appreciated.

function ValidateSurnameCompanyEntered(sender, args)
{
var txtSName = document.WebForm2.txtSurname;
var txtCompName = document.WebForm2.txtCompanyName;
args.IsValid = ((txtSName.text.length>0 && !(txtCompName.text.length < 0))
|| txtSName.text.length> 0 && (txtCompName.text.length < 0));
}
Jul 21 '05 #1
1 1048
Stephen,

The only thing you have to know is if the textbox lenghts are both longer
than 0 than it is an error in your case.

However probably you will as well not that they both are equal to 0.

This is a general newsgroup, when it is a code question, than the newsgroup
microsoft.public.dotnet.languages.csharp is probably a better place.

I hope this helps?.

Cor

"Stephen" <St*****@discussions.microsoft.com>...
Im trying to do a function to validation two textbox controls. I want the
user to enter in text to either txtSurname or txtCompanyName but not both.
Is
my logic wrong and if so can someone help me change this to achieve my
goal.
Im really terrible at this and am under pressure to get it done so any
help
at all would be appreciated.

function ValidateSurnameCompanyEntered(sender, args)
{
var txtSName = document.WebForm2.txtSurname;
var txtCompName = document.WebForm2.txtCompanyName;
args.IsValid = ((txtSName.text.length>0 && !(txtCompName.text.length < 0))
|| txtSName.text.length> 0 && (txtCompName.text.length < 0));
}

Jul 21 '05 #2

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

Similar topics

2
by: Chris Dunaway | last post by:
I have a form with a textbox and numerous panels, buttons and other controls. I have handled the textbox Validating and Validated events. The textbox will hold a filename. In the validating...
0
by: Matthew | last post by:
All, I have searched google and the newsgroups but can't find anything the same as what I am experiencing (though I may have missed something). I have controls (textboxes) within UserControls...
0
by: Gary Shell | last post by:
I am experiencing some strange behavior between a UserControl's validating event and a treeview control. Initially, I thought it was related to an issue in the Knowledgebase article 810852...
3
by: TheSteph | last post by:
Hi Experts ! I have a Winform Program in C# / .NET 2.0 I would like to ensure that a value in a TextBox is a valid Int32 when user get out of it (TextBox loose focus)
1
by: =?Utf-8?B?bGpsZXZlbmQy?= | last post by:
I've noticed that controls do not raise a Validating event if they are contained in a ToolStripDropDown via a ToolStripControlHost item. Please run the following sample and follow the instructions...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.