p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
I forgot my password Register Now
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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 15th, 2004, 10:27 PM
Friend of Wrox
Points: 2,244, Level: 19
Points: 2,244, Level: 19 Points: 2,244, Level: 19 Points: 2,244, Level: 19
Activity: 14%
Activity: 14% Activity: 14% Activity: 14%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 587
Thanks: 1
Thanked 1 Time in 1 Post
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
======================================
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old December 16th, 2004, 01:38 AM
Authorized User
Points: 269, Level: 5
Points: 269, Level: 5 Points: 269, Level: 5 Points: 269, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old December 16th, 2004, 06:12 AM
Friend of Wrox
Points: 1,351, Level: 14
Points: 1,351, Level: 14 Points: 1,351, Level: 14 Points: 1,351, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old December 17th, 2004, 08:47 AM
Friend of Wrox
Points: 1,351, Level: 14
Points: 1,351, Level: 14 Points: 1,351, Level: 14 Points: 1,351, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

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 06:07 AM
Client Side Validation anujrathi ASP.NET 1.0 and 1.1 Professional 1 June 17th, 2006 11:23 PM
client side validation without postback saravananedu ASP.NET 1.1 2 August 7th, 2005 01:22 AM
client-side validation using VBScript larry101 ASP Forms 3 September 2nd, 2004 03:19 AM
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 11:18 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc