Real Estate Forums

Coding HTML, ASP, PHP, JAVA MYSQL and more. All coding questions should be asked here.

Reply
 
Thread Tools Display Modes
Old 04-05-2007, 08:52 AM
RESteve's Avatar
RESteve RESteve is offline
Moderator
 
Join Date: Sep 2005
Location: Houston, TX
Posts: 1,473
RESteve is on a distinguished road
Default Form - Javascript Onblur

Hi Everyone,

I'm trying to get my form to automatically delete the default contents when the user clicks on that field.

I'm can enter some scripting in the javascript onblur, but just don't know what to put in there to make this work.

Basically, the form puts by default an example, and I've been getting form submits with the example text still in place. I'd like for that text to clear itself when the user clicks on that particular form field.

Any help would be greatly appreciated!

EDIT: Wait; is the onblur event after a user leaves the field or when they go into it?
__________________
Steve Castaneda, Realtor
Keller Williams Realty
The MyHomeHouston Team

Specializing in Houston Real Estate. Feel free to visit my Houston Real Estate Blog or read about Real Estate Technology for agents.
Reply With Quote
Old 04-05-2007, 09:06 AM
RESteve's Avatar
RESteve RESteve is offline
Moderator
 
Join Date: Sep 2005
Location: Houston, TX
Posts: 1,473
RESteve is on a distinguished road
Default Re: Form - Javascript Onblur

I got it to work! I used this code:

if(this.value=='original_text') this.value='';

--

I replaced "original_text" with what the default values were, and now they clear if the user leaves that field alone without changing it.
__________________
Steve Castaneda, Realtor
Keller Williams Realty
The MyHomeHouston Team

Specializing in Houston Real Estate. Feel free to visit my Houston Real Estate Blog or read about Real Estate Technology for agents.
Reply With Quote
Old 04-09-2007, 01:53 AM
REW Fergus's Avatar
REW Fergus REW Fergus is offline
Real Estate Webmasters Staff
 
Join Date: Aug 2006
Location: Nanaimo, BC
Posts: 588
REW Fergus is on a distinguished road
Default Re: Form - Javascript Onblur

Quote:
Originally Posted by RESteve View Post
EDIT: Wait; is the onblur event after a user leaves the field or when they go into it?
Focus is when an element gains the input and blur is when it loses it. So when you click in a text box and the insertion point appears, it has been focused. When you tab or click out of that text box, it has lost focus or "blurred".

onfocus is what you're looking for, not onblur.
__________________
Fergus Gibson
realestatewebmasters.com
Reply With Quote
Old 04-09-2007, 06:35 AM
RESteve's Avatar
RESteve RESteve is offline
Moderator
 
Join Date: Sep 2005
Location: Houston, TX
Posts: 1,473
RESteve is on a distinguished road
Default Re: Form - Javascript Onblur

Right; I failed to mention that the form component I'm using doesn't allow me to customize the onfocus; just onblur. No clue as to why.
__________________
Steve Castaneda, Realtor
Keller Williams Realty
The MyHomeHouston Team

Specializing in Houston Real Estate. Feel free to visit my Houston Real Estate Blog or read about Real Estate Technology for agents.
Reply With Quote
Old 04-09-2007, 10:42 AM
REW Fergus's Avatar
REW Fergus REW Fergus is offline
Real Estate Webmasters Staff
 
Join Date: Aug 2006
Location: Nanaimo, BC
Posts: 588
REW Fergus is on a distinguished road
Default Re: Form - Javascript Onblur

Off the top of my head, I'd say all form elements have onfocus events.
__________________
Fergus Gibson
realestatewebmasters.com
Reply With Quote
Old 04-09-2007, 01:00 PM
RESteve's Avatar
RESteve RESteve is offline
Moderator
 
Join Date: Sep 2005
Location: Houston, TX
Posts: 1,473
RESteve is on a distinguished road
Default Re: Form - Javascript Onblur

I'm sure they do; it's just I'm using Joomla, and a Phil-A-Form component that allows back-end administration to create forms. Unfortunately, his software won't allow you to edit the onfocus.
__________________
Steve Castaneda, Realtor
Keller Williams Realty
The MyHomeHouston Team

Specializing in Houston Real Estate. Feel free to visit my Houston Real Estate Blog or read about Real Estate Technology for agents.
Reply With Quote
Old 04-09-2007, 11:20 PM
PLS PLS is offline
Advancing Webmaster
 
Join Date: Jul 2006
Posts: 36
PLS is on a distinguished road
Default Re: Form - Javascript Onblur

Try the ChronoForm extension -- it's pretty flexible, and may allow you to do what you need.
Reply With Quote
Old 04-10-2007, 05:55 AM
RESteve's Avatar
RESteve RESteve is offline
Moderator
 
Join Date: Sep 2005
Location: Houston, TX
Posts: 1,473
RESteve is on a distinguished road
Default Re: Form - Javascript Onblur

Quote:
Originally Posted by PLS View Post
Try the ChronoForm extension -- it's pretty flexible, and may allow you to do what you need.
Thanks. I'll surely give that a go really soon. The biggest pain will be moving all my forms over, but I think if Chronoforms works like it says it does, I can just copy over the source code.
__________________
Steve Castaneda, Realtor
Keller Williams Realty
The MyHomeHouston Team

Specializing in Houston Real Estate. Feel free to visit my Houston Real Estate Blog or read about Real Estate Technology for agents.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



For our members

Main Sections

IDX Coverage Areas

Spiders Welcome

All times are GMT -7. The time now is 07:43 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.