If I fill out the textfields properly with Name, Email etc in a row it
is fine. But if I fill out, for example, my Name, then tab twice, it
clears my entered value. How do I stop this?
All I want the script to do is that when the cell is blank or
whitespace, put the necessary text in the field, else, continue as
normal.
--- HTML Extract
<td width="74%">
<input name="name" type="text" class="textbox" id="name"
onMouseOver="th is.style.backgr oundColor = 'CDEDDD';"
onMouseOut="thi s.style.backgro undColor = 'E2E2E2';"
onfocus="this.s tyle.background Color = 'CDEDDD'; this.style.colo r =
'000000';textua l(name,this.val ue);"
onblur="this.st yle.backgroundC olor = 'E2E2E2'; this.style.colo r =
'000000';textua l(name,this.val ue);"
value="Enter Name" size="30"></td></tr>
-- END Extract
function textual(element ,text) {
var name,company,em ail,worknumber, homenumber,quer y
// If the Field contains the default text, clear it ready for new text
if (text=="Enter Name") { document.form1. name.value = "" }
if (text=="Enter Company Name") { document.form1. company.value = "" }
if (text=="Enter Email Address") { document.form1. email.value = "" }
if (text=="Enter Work Number") { document.form1. worknumber.valu e = ""
}
if (text=="Enter Home Number") { document.form1. homenumber.valu e = ""
}
if (text=="Enter your query here...") { document.form1. query.value =
"" }
// If the Field is blank, re-write the contents
if (text=="") {
if (element="name" ) { document.form1. name.value = "Enter Name" }
if (element="compa ny") { document.form1. company.value = "Enter
Company Name" }
if (element="email ") { document.form1. email.value = "Enter Email
Address" }
if (element="workn umber") { document.form1. worknumber.valu e = "Enter
Work Number" }
if (element="homen umber") { document.form1. homenumber.valu e = "Enter
Home Number" }
if (element="query ") { document.form1. query.value = "Enter your query
here..." }
}
} 2 1820
On 19 Apr 2004 06:31:26 -0700, RelaxoRy <re******@postm aster.co.uk> wrote: If I fill out the textfields properly with Name, Email etc in a row it is fine. But if I fill out, for example, my Name, then tab twice, it clears my entered value. How do I stop this?
All I want the script to do is that when the cell is blank or whitespace, put the necessary text in the field, else, continue as normal.
[snipped code]
You can modify your code to be considerably smaller:
function clearInput( control ) {
if( control.default Value == control.value ) {
control.value = '';
}
}
function restoreInput( control ) {
if( '' == control.value ) {
control.value = control.default Value;
}
}
<input ... onfocus="clearI nput(this)" onblur="restore Input(this)">
Hope that helps,
Mike
--
Michael Winter M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)
Ahhh of course!
It worked a treat. Must keep remembering everything is recorded.
Thanks.
--
The way of the goat is many.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: threepins |
last post by:
Howdy,
Just wondering how the following might be done:
I have a couple of different webpages that need to call a function to
clear the textbox onFocus of the textbox. I'm wanting to use one
function that I can call from a javascript include file (rather than
having multiple versions of the function all through the site).
So far i've tried the following:
|
by: Savvas |
last post by:
Hi everybody,
I have a lot of textboxes on my form and a "Clear" button. Is there a
way with a for loop or something to clear the textboxes, instead of
writing textboxName.clear?
Thanks a lot
|
by: Omar Llanos |
last post by:
I have Form1 and Form2 (which is inherited from Form1), and I created a
button in Form2 that will fill up a textbox in Form1. What code would do
that?
I tried the simplest way:
//from child form in button2 clicked event:
textbox1.Text = "Hello";
|
by: Hazzard |
last post by:
I just realized that the code I inherited is using all asp.net server
controls (ie. webform controls) and when I try to update textboxes on the
client side, I lose the new value of the textbox when submitting the form to
update the database. The server doesn't have the client side value any more.
It seems to me that as I begin to write the client side javacript code for
form validation and client side editing capabilities in order to save...
|
by: Ali |
last post by:
I used to clear my page's control in Visual Studio 2003 using code like this:
Dim c As Control
For Each c In Page.Controls(1).Controls
If TypeOf c Is TextBox Then
CType(c, TextBox).Text = Nothing
End If
If TypeOf c Is DropDownList Then
CType(c, DropDownList).SelectedIndex = 0
End If
Next
| |
by: RLN |
last post by:
Re: Access 2003
I found a method here in the newsgroup that works for clearing
checkboxes, but don't understand a particular line of code and how it
works.
Here is the code:
1. Dim ctrl As Control
2. For Each ctrl In Me.Controls
3. 'uncheck all of the checkboxes...
|
by: Radu |
last post by:
Hi.
I have... well.... not very many computer-literate users to my web-
site.
For the textbox which expects an email address, for instance, I had to
enter a default text like
"Email..." because if not, they phoned me asking questions like "What
does the message 'Your email address is required' ?" :-)))
|
by: Angel Blue01 |
last post by:
I have a form with a binding navigator that draws from a database via
drag-and-drop-created controls. I'm filling a listbox with the results
of a query. The listbox contains data related to the record that the
user is viewing but cannot be databound because other events and user
input are needed when the user selects an item from the listbox.
Each time the user clicks the binding navigator to move to the next
record I have this:
<code>
|
by: asumal |
last post by:
Hello
I am new to ASP.NET. I am using CreateUserWizard control to register & create a user. I am using Membership API. I have a Cancel button on the CreateUserWizard step 2 alongwith Create User button & Previous button. Actually, i have added some more textboxes on the default control for taking user's personal information. The problem is that when i call the below mentioned code all textboxes for user's personal information gets cleared...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |