regarding java script error

Last post 05-14-2008 5:54 AM by iftekharul. 3 replies.

Sort Posts:

  • regarding java script error

    05-14-2008, 3:48 AM
    • Member
      4 point Member
    • amit_bhagat
    • Member since 05-03-2008, 12:25 PM
    • Posts 10

     

    hi guys 

    i am working with asp.net with vb as a language. 

    I got a login page code.in this page i got 2 fields username & password.

    when i login  the page i am getting the error below the browser which says object required.

    this error is with java script which  have been written on hte page.

    the line on which i am getting error is as shown below


         if (document.getElementById("txtusername").value ==document.getElementById("txtNewPass").value )

    can anybody  help me out with this one

    thank you

    my email id is

    amit.bhagat@ril.com

  • Re: regarding java script error

    05-14-2008, 4:08 AM
    Answer
    • All-Star
      28,218 point All-Star
    • johram
    • Member since 06-13-2006, 10:36 AM
    • Sweden
    • Posts 3,543
    • Moderator

    You should avoid hard-coding the name of the control in your JavaScript code as it might cause exactly the type of problem you're experiencing. Please see my previous post: http://forums.asp.net/p/1248828/2303141.aspx for a solution to this.

    If this post was useful to you, please mark it as answer. Thank you!
  • Re: regarding java script error

    05-14-2008, 4:45 AM
    • Member
      356 point Member
    • krishnav
    • Member since 05-01-2008, 9:45 AM
    • Vijayawada
    • Posts 80

    Hi,

    var oldpwd= document.getElementById("txtpwd1").value;

    var newpwd= document.getElementById("txtpwd2").value;

    if(oldpwd==newpwd)

    {

    //content

    }

    if it is not working then send ur full code .. what u wrote..

  • Re: regarding java script error

    05-14-2008, 5:54 AM
    • Member
      26 point Member
    • iftekharul
    • Member since 05-06-2008, 2:35 PM
    • Dhaka, Bangladesh
    • Posts 9

    I have a question here. Are the IDs provided for text are set for asp web controls <asp:Text> ? In that case from JS, you'll have to write like this:
    if (document.getElementById("<%= txtusername.ClientID %>").value ==document.getElementById("<%= txtNewPass.ClientID %>").value )


     

    M Iftekharul Anam
    Web/UI/Asp.Net AJAX Consultant
    Web 2.0 Ninja
Page 1 of 1 (4 items)