Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 26th, 2005, 10:06 AM
mh mh is offline
Authorized User
 
Join Date: Mar 2005
Location: , , .
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default Checking to see if a label's text is empty

Hi,

I've been getting errors saying "Object required" when I try to check the contents of a label's text. I'm trying to have the function execute only if the label's text is blank. The following is my code:

    <script>
  function NewWindow()
  {
    if (document.getElementById("txtpostdte").value != "")
    {
        var rptdate=document.getElementById("txtpostdte").valu e;
        var err=document.getElementById("lblerror").innerHTML;
        if (err = "")
        {
        window.open("TyDly.aspx?postdte=" + rptdate);
        }
    }
  }
        </script>

The error is pointing to where I set the variable 'err' equal to the lblerror's text. Is there something I'm doing wrong? I tried .innertext, .text, .value and still nothing works. In addition, is there any chance that I can combine both the txtpostdte and lblerror's conditions together? When I try to do it, I get an error. Any help is greatly appreciated. Thanks.

And, I'm not sure if this is the forum to post this in. If not, can someone please point me in the right direction? Thanks again.

 
Old October 26th, 2005, 10:35 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You're better off posting this in the JavaScript forum, under the Web category. This forum is for ASP.NET 2.0, the new ASP.NET version from Microsoft.

That said, look at this:

if (err = "")


You're not comparing, you're assigning.

if (err == "")

compares err against ""

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old October 26th, 2005, 10:38 AM
mh mh is offline
Authorized User
 
Join Date: Mar 2005
Location: , , .
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you, Imar. I will move it there.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking to see if a label's text is empty mh JSP Basics 2 October 26th, 2005 11:05 AM
Help checking for empty dataset Payback ASP.NET 1.0 and 1.1 Basics 5 March 28th, 2005 05:00 AM
Checking for empty string richw32001 General .NET 1 August 8th, 2004 01:37 PM
checking for empty recordsets ! spraveens Classic ASP Databases 0 September 9th, 2003 10:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.