Results 1 to 6 of 6

Thread: Using Javascript in .NET

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2002
    Location
    Madras
    Posts
    50

    Question Using Javascript in .NET

    Hi,

    i need to validate my form using javascript... how it can be done...

    For eg take a change password screen which prompts for old password, new password and confir new password.. i need to validate whether the new password and confirm new password are same..

    Thanks in adv

    venkat
    venkat

    Strength is Life, Weakness is Death

    - Swami Vivekananda

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

  3. #3
    Member
    Join Date
    Mar 2005
    Posts
    56

    Re: Using Javascript in .NET

    meh, I was bored, asside from the given links, maybe you can do away with this example:
    PHP Code:
    <html>
    <
    head>
    <
    script type="text/javascript">
    function 
    passMatch(e)
    {
        var 
    pass e.pass;
        var 
    confirmPass e.confirmPass;
        if(
    pass.value != confirmPass.value || pass.value == "")
        {
            
    alert("Your passwords do not match!");
            
    pass.select();
            return 
    false;
        }
        else
        {
            return 
    true;
        }
    }
    </
    script>
    </
    head>
    <
    body>
    <
    form name="myForm" action="" method="" onsubmit="return passMatch(this);">
    Old Password:<input type="password" name="oldPass"><br>
    New 
    Password:<input type="password" name="pass"><br>
    Confirm new Password:<input type="password" name="confirmPass"><br>
    <
    input type="submit" value="Change password">
    </
    form>
    </
    body>
    </
    html

  4. #4

    Thread Starter
    Member
    Join Date
    Jun 2002
    Location
    Madras
    Posts
    50

    Re: Using Javascript in .NET

    Thanks man...

    but i'm using <asp:textbox> how to capture this using javascript while submitting the form
    venkat

    Strength is Life, Weakness is Death

    - Swami Vivekananda

  5. #5
    Member
    Join Date
    Mar 2005
    Posts
    56

    Re: Using Javascript in .NET

    The id would be the same as the name, so if your text box id's are 1 and 2:
    PHP Code:
        var pass e.TextBox1;
        var 
    confirmPass e.TextBox2

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Using Javascript in .NET

    You can use the CompareValidator control, and use it to check whether they both have the same value.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width