Results 1 to 3 of 3

Thread: Text Changed on Web Form

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2009
    Location
    Milan
    Posts
    810

    Text Changed on Web Form

    I want to change the color of my background on a textbox when the user typers stuff. For example I have two textboxes password and confirm password. On the second one if the passwords match i'm going to make the back color white if not red.

    I can do this on WinForms easy as, same code on Web Forms and nothing happens

    How do i do this???

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Text Changed on Web Form

    document.form.txtPassword.style.backgroundColor = "#FFFFFF";

    The above will change the textbox background color. You need to set this in the javascript method.

    Hope this helps


    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
     "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="Content-Script-Type" content="text/javascript">
    <meta name="Content-Style-Type" content="text/css">
    <title>Example</title>
    
    <script type="text/javascript">
    
    function checkform()
    {
    	var pass=document.getElementById('txtPassword');
    	var confirmpass=document.getElementById('txtconfirmPassword');
    	if (pass.value != confirmpass.value)
    	{
    	  pass.style.backgroundColor = "#FFFF00";
    	  confirmpass.style.backgroundColor = "#FFFF00";
    	  alert('Passwrod doenst match');
    	  return false;
    	}
    	
    	return true;
    	
    	
    }
    
    </script>
    
    <style type="text/css">
    form { margin:auto; width:11em}
    fieldset {padding:1ex}
    label {display:block; margin:0; text-align:left}
    label.highlight {background-color:#aaa}
    label.highlight input {background-color:#a00}
    button {display:block; margin:auto}
    </style>
    
    </head>
    <body>
    <form onsubmit="return checkform();">
    <fieldset>
    <legend>Example</legend>
    <label>Password<input type="PASSWORD" Name="txtPassword"></label>
    <label>Confirm Passwrod<input type="PASSWORD" Name="txtconfirmPassword"></label>
    
    <button type="submit">Submit</button>
    </fieldset>
    </form>
    </body>
    </html>
    Please mark you thread resolved using the Thread Tools as shown

  3. #3
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Text Changed on Web Form

    Hello,

    Based on what you have asked, I am assuming you are trying to allow the creation of users on your website. Have you considered using the ASP.Net Membership Provider, and it's associated controls? For instance the CreateUserWizard and the ChangePassword control would handle all of this work for you.

    Gary

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