CodeVerge.Net Beta
Login Idy
Register Password
  Forgot?
Explore    Item Entry    Members   
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML





Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 1/13/2004 8:04:10 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 2 Views: 15 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
3 Items, 1 Pages 1 |< << Go >> >|
mikesolo
Asp.Net User
Using Required Field Validators To Validate That At Least One Textbox Has Contents1/13/2004 8:04:10 PM

0/0

Hello:

Taking a break from my busy schedule of coding and cow-milking to write this post. I have a situation where I have two fields, an email address and a phone number, and at least one is required. However, putting two required field validators on these fields would cause both to be required. I have done some experimentation into creating a custom control that inherits the required field validator, but adds a second control, but have not had sucess with it. Does anyone have any ideas how this could be done?

Thanks,

MushroomMan
master4eva
Asp.Net User
Re: Using Required Field Validators To Validate That At Least One Textbox Has Contents1/13/2004 9:39:35 PM

0/0

Hi,

This type of validation is not normal. However, you can still use some code such as the following:

rfv1.Validate();
rfv2.Validate();

if (rfv1.IsValid || (rfv2.IsValid) {
// is valid
}

One thing that is required for you to do is for the post-back buttons do not cause validation:

<asp:button causesvalidation="false" ... />

-- Justin Lovell
goblyn27
Asp.Net User
Re: Using Required Field Validators To Validate That At Least One Textbox Has Contents1/25/2004 12:42:53 AM

0/0

I would recomend using a customervalidator control to handle that situation if you just want a quick and easy solution that doesn't involve creating new server controls.

add a customer validator to the page where ever you would like it to display and set its properties like you would any other validator control with three exceptions

1) Do not assign it a ControlToValidate property. This way it will not be coupled with any specific control

2) assign the ClientScript property to an arbitary javascript function you have added to the page. for instance


function myClientValidate(source, arguments)
{
arguments.IsValid = true;
with (document.Form1)
{
if (textbox1.value.length < 1 && textbox2.value.length < 1) arguments.IsValid = false;
}
return;
}


3) Assign the OnServerValidate property of the validator to an appropriate serverside script function so that it still evaluates on postback as well
3 Items, 1 Pages 1 |< << Go >> >|



Search This Site:


Meet Our Sponsors:



Other Resources:

Modules exist in the folders.. other modules give errors - ng.asp-net ... Chad Myers' Blog It uses, among other things, the Profiler API in order to ... using required field validators to validate that at least one textbox has contents ...
Cannot read Thai characters inserted by Message Broker in DB2 and - ibm ... using required field validators to validate that at least one textbox has contents ... accessing content page control from master page. vwd not working ...
CodeProject: ASP.NET Required TextBox (Graphical RequiredFieldValidator ... ... on Error", "Validator", "The required validators SetFocusOnError")); coll.Add ... that validates a group of fields in which at least one is required, like ...
CodeProject: Multiple Fields Validator - An ASP.NET Validation Control ... Discussing the MultipleFieldsValidator that validates a group of fields in which at least one is required, like phone number, mobile phone number, or email. It ...
required field validators and not validating until submit button clicked attempted to be submitted) at least once. This allows ... Generated JavaScript vs. Manually Created JavaScript: Which one comes first? Sharing a Validator ...
CS 351 Wiki Notes: Day 8 Range validators also allow one to specify a type. ... a text box, a button, and a required field validator on the page as shown in the ...
Web Apps: An Overview Of The New Services, Controls, And Features In ... ... build content pages—ASPX files—that reference the master using directives like this one: ... the amount of code required to validate logins and manage ...
CS 351 Wiki Notes: Day 10 [0-9]+$ matches at least one digit at end of line. matches zero or more ... the required field validator, add a Reqular Expression Validator control to ...
DB2 ASP.NET input validation with Delphi for .NET and C#Builder ... use the CompareValidator to validate the type of input for the PHONENO field, by ... Note that as long as at least one client-side validation constraint fails, it ...
InformIT: .NET Reference Guide > Validating User Input in ASP.NET Web Pages ... validator to TextBox1 and set the ErrorMessage field to "This is a required field" ... If IsValid is False, then you know that at least one validation failed. ...
Extending Windows Forms with a Custom Validation Component Library, Part 1 Introducing the Required Field Validator. BaseValidator: Divide and Conquer ... Uses a regular expression to validate a field's format. CompareValidator ...
InformIT: Using the Validation Controls in ASP.NET 2.0 > Overview of ... ... to submit a form at least once or you enter and remove data in a form field. ... That way, if other content is displayed next to the validation control, the ...


 
All Times Are GMT