473,322 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Login box text

384 256MB
I have two text boxes for a login page, they have a value in them as default, when a user clicks on one of the text boxes I want the default value to disappear and if the user doesn't enter anything and clicks away I want the default value to come back but if the user enters something then that value remains in the text box.

I was thinking that the onFocus and onBlur events would be the way to do it?

Anyone any tips on how to go about this?
Jan 5 '10 #1
2 1861
ziycon
384 256MB
This is the code I'm using but when I click on the username box it removes the text and when I click away from it it will add in the default text but it empties the password box, any ideas?
Expand|Select|Wrap|Line Numbers
  1. <SCRIPT TYPE="text/javascript">
  2. <!--
  3. function clearField(input,cValue) {
  4.     if(cValue == 'username' || cValue == 'password')
  5.         cValue = '';
  6.  
  7.     if(input == 1 && cValue == '')
  8.         document.login.user.value = "";
  9.     if(input == 2 && cValue == '')
  10.         document.login.pass.value = "";
  11. }
  12. function setField(input,nValue,cValue) {
  13.     if(input == 1 && cValue == '')
  14.         document.login.user.value = nValue;
  15.     if(input == 2 && cValue == '')
  16.         document.login.pass.value = nValue;
  17. }
  18. //-->
  19. </SCRIPT>
Expand|Select|Wrap|Line Numbers
  1. <input type="text" name="user" size="25" value="username" class="loginBox" onclick="clearField(1,this.value);" onBlur="setField(1,'username',this.value);" />
  2. <input type="password" name="pass" size="25" value="password" class="loginBox" onclick="clearField(2,this.value);" onBlur="setField(2,'password',this.value);" />
Jan 5 '10 #2
acoder
16,027 Expert Mod 8TB
Hmm, I don't see that. Is the password text really necessary, because you can't see what it says anyway?
Jan 8 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: John Davis | last post by:
I put a little login (username and password textfields) in a web page, and once the user able to login, I want the username and password textfields will disappear, and replace with text " has...
11
by: David W. Simmonds | last post by:
I have a form that will prompt for a user name/password. In VS.NET, I have the protected form in a folder named Admin. I have a Web.config file in that folder as well. It contains the following...
2
by: Assimalyst | last post by:
Hi, I am creating a website where i want to allow some webforms to be accessible to all users, and those in a subdirectory available only to authenticated users. I have created a script to...
3
by: Bruce | last post by:
I just started the design of an ASP.NET application which accesses one of our custom web services to provide user authentication, among other purposes. I created a log-in page (code below),...
0
by: John Meyer | last post by:
index: <%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.OleDb" %> <!DOCTYPE html PUBLIC...
6
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in...
1
by: bobmct | last post by:
Again: struggling to convert old-style HTML to html using css. I am trying to create a rectangular box divided into approx three vertical sections. The top section contains an image I would like...
0
by: jobs | last post by:
This code works at setting my login failure message, but does not set the color for some reason. Protected Overrides Sub OnLoad(ByVal e As EventArgs) If IsPostBack Then If Login.FailureText <""...
9
by: adweaver | last post by:
Hello All, I'm new to the world of php. I've just had a site designed for me by a company, and I'm now trying to manage and grow it, so it will suit my needs. The site was built in a folder...
1
by: punk86 | last post by:
Hi, i can register and login without fail. However i notice that my inputs are not record into the database. I do not know the reason. Can someone guide me into login and register. Actually im...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.