Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OnBlur Java function

Status
Not open for further replies.

AndyLord

Programmer
Jun 30, 2004
45
GB
Can anyone help.
What I want to achieve is when a user types in a contact name then tabs to the next field, the email field will be automatically filled with the contact name and @whatever.net. I know it has something to do with teh java script function of Onblur="this value" but I have lost the code and didn't make a copy of it. Silly me.

Something like Onblur="this.value (txtContact)whatever.net".

Many Thanks in advance for any help.

 
JavaScript. "Java" is something else entirely.

Code:
<html>
<head>
<title>tgreer sample code</title>
</head>
<body>
<form>
  <input type="text" id="fullName" onblur="document.forms[0].email.value = this.value + '@whatever.net';"/><br/>
  <input type="text" id="email"/>
</form>
</body>
</html>



Thomas D. Greer

Providing PostScript & PDF
Training, Development & Consulting


Haiku workshop and community.
 
tgreer

You right, I did mean javascript and you supplied what I required.

Many thanks

Andy Lord
 
tgreer

One more question, if I were to replace the space " " within a name with a "." would this be the best method:

onblur="document.forms[0].email.value = this.value.replace(' ', '.')+'@whatever.net';" />

I have tried this but it does not seem to work.

Many thanks in advance

Andy Lord
 
You need a space in there:

Code:
<html>
<head>
<title>tgreer sample code</title>
</head>
<body>
<form>
  <input type="text" id="fullName"
    onblur="document.forms[0].email.value = this.value.replace(' ','.') + '@whatever.net';"/><br/>
  <input type="text" id="email"/>
</form>
</body>
</html>

Thomas D. Greer

Providing PostScript & PDF
Training, Development & Consulting


Haiku workshop and community.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top