Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Client Validation Function for ASP.NET

Status
Not open for further replies.

Peppi

Programmer
Apr 9, 2001
205
CA
Hi,

I'm trying to write a client validation function to be used by my ASP.NET CustomValidator control. Here is what I currently have:

Code:
function validateDays(sender, args) {
    var days = parseFloat(args.Value);

    if ((days > 0) && (days <= 1)) {
        args.IsValid = true;
	return;}
    else {
	 args.IsValid = false;
         return;}}

In this function, sender is the CustomValidator control. Now, I need to enhance this so that this validation only occurs when a particular textbox control is enabled. Since both the TextBox and CustomValidator are built up dynamically as part of a GridView control, there is no way to predict what the id property will be.

Does anyone know how to get at the TextBox control so that I can check whether or not it is disabled?

Thx.
 
How many <input> tags are on the page??

If that answer is more than 1, how many textboxes are on the page?

Based on this we may be able to get to that textbox.

[monkey][snake] <.
 
Hi,

Thanks for your reply.

I actually just figured out how to solve this. The following line returned the control to me:

var days = document.getElementById(sender.controltovalidate);

Thx.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top