|
|
 |
| 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.
|
 |

December 15th, 2004, 10:27 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: , , Australia.
Posts: 587
Thanks: 1
Thanked 1 Time in 1 Post
|
|
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>
<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
======================================
|

December 16th, 2004, 01:38 AM
|
|
Authorized User
|
|
Join Date: Aug 2004
Location: , , .
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|

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
|
|
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.
|

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
|
|
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 |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |