Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 15th, 2004, 10:27 PM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default Custom Validation Control Client side event

Hi,

A have the need for a custom validation control to test the comination of a textbox being checked and that a field is not left blank.
It appears that the custom validation event does not fire when the ControlToValidate is left blank.
I cant use the RequiredFieldValidator because it does not allow me to test the checkbox.

I guess I could put in a hidden textbox and use it as the ControlToValidate with some content just to fire the client event.
And then test the correct field length throught javascript ignoring the args.Value of the validator.

BUT this seems like a poor method.
Doen anyone know the correct way to do this.

An simplified example of the situation is below.
This ignores the checkbox situation but if the code is run you will see that the client side event only fires when something is in the textbox.

Code:
<HTML>
  <HEAD>

        <script language="JavaScript">
function validateNumber(oSrc, args) {
alert('Boo');
args.IsValid = (args.Value.length > 3);
}
        </script>
</HEAD>
    <body>
        <form runat="server" ID="Form1">
            <p>
                Number:
                <asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
                &nbsp;
                <asp:CustomValidator id="CustomValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="The input must have at least 4 characters"
                    ClientValidationFunction="validateNumber"></asp:CustomValidator>
            </p>
            <p>
                <asp:Button id="Button1" runat="server" Text="Button"></asp:Button>
            </p>
            <p>
                <asp:Label id="Label1" runat="server"></asp:Label>
            </p>
        </form>
    </body>
</HTML>
Any assistance would be appreciated

======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
__________________
======================================
"They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad."
--Shakespeare
======================================
  #2 (permalink)  
Old December 16th, 2004, 01:38 AM
Authorized User
 
Join Date: Aug 2004
Location: , , .
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have exactly same problem. I need to test two textboxes. If you look at my thread that is still active:-
http://p2p.wrox.com/topic.asp?TOPIC_ID=23253

I cannot use customvalidator or requiredfield validator. I am planning to test it on the server side. Let me know if you find a better solution. I guess this is the only solution.

  #3 (permalink)  
Old December 16th, 2004, 06:12 AM
Friend of Wrox
 
Join Date: Jul 2004
Location: Tehran, , Iran.
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:Originally posted by Renu


I cannot use customvalidator or requiredfield validator...
Hi again,
no,you can use them but in server-side(now in server-side you cant show po pup window anymore).

_____________________________
Mehdi.
software engineering student.
Looking for a good job for summer 2005.
  #4 (permalink)  
Old December 17th, 2004, 08:47 AM
Friend of Wrox
 
Join Date: Jul 2004
Location: Tehran, , Iran.
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Rod,
There are two ways in this regard,
1-you want to validate them on the serve-side,
2-you want to validate them on the client-side,
it's clear checking them on the client-side results in better performance,so if you want to work-
on the client-side it's better to ignore such validators and work just with JavaScript,there would
be no need for hidden textboxes anymore,
but if you want to work on the server-side,you can use such validators easier,
(but ignore client-side facilities like showing po pup windows and ...),
(for more info you can have a look at Renu's thread).

_____________________________
Mehdi.
software engineering student.
Looking for a good job for summer 2005.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is client-side validation in ASP.NET 2.0 possible? jacob ASP.NET 2.0 Basics 6 April 10th, 2007 05:07 AM
Client Side Validation anujrathi ASP.NET 1.0 and 1.1 Professional 1 June 17th, 2006 10:23 PM
Posting form After Custom Client-side validation rathbird General .NET 3 March 4th, 2004 06:03 PM



All times are GMT -4. The time now is 07:23 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.