Clearing A Form Field Once

Apr 9, 2001

I have a page with multiple text fields, each of which has an example for an initial value. I've added the appropriate code so that onFocus() the example is cleared away, and a blank field is left behind. Trouble is, I only want that to happen once, so that the field isn't cleared if the user attempts to edit what they wrote earlier. Anybody know of a way to do that with only a few lines of code? Here's my existing code:


Code:
<script language="JavaScript">
<!--
function clearField(fieldName) {
fieldName.value = "";
}
// -->
</script>

<p>Person's Name: <input type="text" name="name" size="30"
value="John Smith" tabindex="2" onFocus="clearField(this)"></p>

View 2 Replies


ADVERTISEMENT

Form Field Not Clearing Out After Submitting?

Mar 30, 2011

I installed a JS form dependency script. Basically if a checkbox is checked Field A will disappear and Field B will take its place.The script appears to work fine. The problem I am having is this. If someone submits the form using the Field B entry and then they need to submit a form using the Field A entry, the Field B entry is still being passed even though is it is not displayed and Field A has a value in it!So I guess my question is, how do I flush out the form field after the form is submitted? This is just happening with the fields where there is the JS Form Dependency script involved.

View 2 Replies View Related

JQuery :: Form Field Clearing Script?

Apr 4, 2010

I have the following code that I'm using to cycle through each element in a form field, and clear whatever text is in it. If the user clicks out of the field without typing anything then the script is supposed to return to whatever value it started with (e.g. "Enter your name..."). If the user does type something, then it stays in the field even when they click out of it:

[Code]...

View 9 Replies View Related

JQuery :: Detecting Field Value On Page Load And Clearing Field Label

Oct 14, 2010

I'm having trouble detecting if there is value in a field when the page loads and manipulating the fields label class accordingly. Below is my code. I'm using it to display the field label inline with the field, and when the user starts typing, the label is hidden. The problem I'm having is, since this is for a login screen, if the user has typed in an incorrect password, the username still remains entered when the page reloads and I see my label stacked underneath.

How can I detect if that field has a value and apply a class to the label to hide it? I don't have to have to specify each field by their ID, because I'd like to use this all over (member profile management area).

[Code]...

View 7 Replies View Related

Reselecting A Text Field To Edit Without Clearing Current Value?

Jan 6, 2011

I'm currently designing a form with client-side validation using javascript. I've set the input property to display as the value (for example, "your name" inside the name field) and I've set the javascript to clear value using name.focus but everytime I reselect the field to edit the value, it clears again, so I'm trying to make it so that on the 2nd time it get's selected, the nameClear funtion doesn't run.Here's what I've got so far, but it's not working. For some reason, the else statement within the function that runs on .focus is showing as invalid in my debugger, but it looks fine to me.

name.focus(function() {
if(name.val("Your name"))
name.val("");

[code].....

View 2 Replies View Related

Clearing Form Fields

Sep 6, 2007

I have a page with 5 sets of form fields. Each field set has a checkbox that if checked will allow users to utilize it. I want to clear the given field set when the user un-checks the check box. As you can see in the code below this method will make for a very long and cluncky script, I would like to make it more generic.

<script>
function clear() {
window.document.roles.foo1.checked = ''
window.document.roles.foo2.checked = ''
}
</script>
<input class="checkBox" />
<input checked name="foo1" type="checkbox" class="checkBox" />
<input checked name="foo2" type="checkbox" class="checkBox" />

View 2 Replies View Related

Clearing Default Form Values On Submit

Oct 8, 2010

I've read a few solutions to this, but none seem to fit what I'd like to do. I'm quite new to JavaScript, so I'm trying to learn various solutions to problems and also what can and can't be done.

What I'd like to know is can you, on submit, check all the form values on a page, or indeed within a specific form on a page, for their default values, and if any still have their default values as the text within that box, clear that value.

So using some generic form values as an example, if I had a form that had three text fields Name, Email, and Phone, all by default populated by their respective names, if someone changed the value of Name to "Adenv" but left the other two, on submit the script would change the values to:

With *blank* indicating a blank field. Is this possible?

View 3 Replies View Related

JQuery :: Submit Form - Clearing Text Fields

Jul 24, 2010

I am using jQuery AJAX to submit a form. When the data has been validated successfully and processed, I want to clear the form, but I am unsure how. I have been trying to make it work for a few hours now.

I am showing status messages in the container below:

When everything was successful, it looks like this:

And here is the simple code I use to clear the text fields:

What I need is a way to check if everything was successful and if so, then run the code above. I tried to do it in a few ways, but it kept clearing regardless of the status.

View 18 Replies View Related

Two JS Questions In One: Giving Focus, And Clearing Form (read Inside)

Jul 23, 2005

Okay, how do I write a page with a form so that when I click Submit,
the following happens?

1. The data is submitted (of course)
2. The form is cleared (what I've tried results in the form being
cleared first, resulting in an empty submission), and
3. The cursor goes back to the start of the form, ready for more input
(kind of like how Google puts the cursor in the search box at the
start).

I can't seem to find the answer, and I've been looking on the net for a
few hours already.

View 2 Replies View Related

JQuery :: Reset Form Not Clearing Validation Error Messages

Jul 4, 2010

I'm using the form validation and it's working great. But the form reset button, although it clears the form fields, does not clear the errors. My page header has this code so far:

[Code]....

I'm trying to understand how to implement the following in order for the reset button to do that:

var validator = $("#myform").validate();
validator.resetForm();

I'm not an experienced JS person but have a lot of other programming experience (vb, vba, mssql, delphi).

View 2 Replies View Related

Copy And Paste Form RTF Document Into Field In Asp Form Cause It To Bypass Field Length And Javascript Validation - How To Overcome?

Jul 23, 2005

I have a web form with several fields. If I copy & paste from a RTF document into a field, the javascript validation and field length are bypassed and cause the form to fail.

View 3 Replies View Related

Jquery :: Form Field Clear \ Form Field Reset?

Nov 12, 2011

i think this will help people a lot, cuz i couldn't find any simple answer by googling 3 hours...i need a very very simple jquery form field reset.here is the picture what i need:


HTML Code:
<script type='text/javascript' src='http://code.jquery.com/jquery-1.6.4.min.js'></script>
<script>

[code]....

View 2 Replies View Related

Form Validation Field Values Not Saved If One Field Is Not Completed/invalid?

Feb 3, 2009

The following form validation script works, currently if one of the five fields are completed, a message appears the remaining field(s) must be completed etc. Although the information the user has inputted in the first field is cleared. How can this information be available, if there is one problem in the form it doesn't make sense that the user must re-input all the information again. I look forward to hearing your response,

function validate_form ( )
{
valid = true;

[code]....

View 1 Replies View Related

Only Validating One Field At A Time In A Multi Field Form?

Aug 17, 2010

my javascript code is only validating one field at a time (as in it validates on field then submits the form, instead of going through the entire thing and then returning it as true and submitting it...) I'm not sure what to do to be honest, I've looked up google to no real avail.. my variables are declared in a seperate file to the actual even handlers and I have heaps of comments through out it, so please don't judge lol i'm still learning Quote:

//Event Registrations (Variable Declarations) found in validation_chkr.js
//Validate Entire Form using validate_join()
function validate_join()

[code]....

View 14 Replies View Related

Calculate Field Based On Another Field In Form

Jul 23, 2005

Is there a way I can calculate a field in a form based on another field in
the same form. When clicking submit, both values should be posted to the
next page. I want to be able to type in a value in one field, and
automatically in a second field the value*1,36 should appear.

View 6 Replies View Related

Copy Date From Field To Field In A Form

Feb 15, 2006

I have a site for property bookings with 2 calendars to enter start and end date. The calendar im using doesnt have any obvious facility to copy yhe date to 2 fields so each one has to be done, months in advance this can be a real pain.

Does anyone have any ideas how i can take the data inserted into one field and copy it to the second?

View 3 Replies View Related

Invoice Form - User Can Add - Input Field - After Adding A New Input Field - The Content In The Other Fields Is Deleted

Sep 1, 2011

I'm now working on kind of invoice form which in it the user can add as much input field as he wants.

The problem is that after adding a new input field - the content in the other fields is deleted.

Code:

View 8 Replies View Related

JQuery :: Add Fixed Value To Form Input And Send To Separate Form Field

Jun 3, 2011

I've have a function to take the value entered in a form text box, add 50 to it and put the result in another text box.

When I enter 650.5 I get 700.5 exactly how I'd expect. But when I enter -650.5 instead of getting -600.5 I get -650.050 as though it is failing to parse the float due to it being negative. My understanding of parseFloat was that it recognises negative numbers. Is there a nice simple way to get this to work?

View 1 Replies View Related

Pass User Input From A Form To One Database Field Using Several Form Elements

May 4, 2009

I need to pass user input from a form to one database field. I'm relatively new to JS but the idea I had was to have several form elements and use JS to collect the users input and send all the values through a hidden element. What's happening is the variable names are being sent rather than the values. The code below is only passing to the next page. Limitations: I am editing an intranet site built by a 3rd party so a lot of the files we've been given are encrypted. I cannot change the method to post.

[Code]....

View 3 Replies View Related

Populate A Form's Field (via Hyperlink) Without Access To The Form's Code?

Mar 3, 2011

I work for a very large company that has zero communications between IT and the employees...so there is very little possibility of having any code changed.I need to use a web based system that submits orders for my department. The problem is i must order by "task number". I could have 20-30 task numbers so to complete the order I need to go to my company's page and fill out 15 form fields and submit for each task code. It is a terrible pain. 14 of the 15 fields are the same for each order... only the task code changes.

View 7 Replies View Related

Form Validation Styling Form Field Borders Green If Ok And Red If Not?

Sep 24, 2009

I've set up a mock registration form page so I can learn a bit about javascript's form validation. (newbie) I want to try to attempt to style the border of a form field green when the user enters the correct info into the form text field and red on all other fields if the user doesnt enter any info into them. When i test it, enter the right info into the username field, leave the others blank, and hit the submit button it styles the username field green ok but it doesnt make the next fields (password and so on) red. just for testing purposes I've put return false on everything so it displays a message when everythings ok.[code]

View 3 Replies View Related

Reset Form Field When Form Submitted To Frame

Oct 3, 2003

Am creating a framed chat application and when the user types a message in the form field and clicks the submit button, the message gets sent to the display frame, but the message stays in the form field. How can i get the form to submit the message AND reset the form field to blank too?

View 1 Replies View Related

Form Field With Same Name As Js Form Property--workaround?

Jul 23, 2005

I'm trying to do some javascript form validation and I've discovered a
rather difficult situation to handle with IE.

Let's say there's a form with three input fields named "name",
"method", or "length". Whenever my javascript tries to access the
form's name or length, and the form happens to have input fields named
"name" and "length", I'm actually accessing the input fields and there
seems to be no way to access those properties of the form.

I have an easy workaround for form.length, so there's no need to give
me a workaround for that one, but there's a bigger issue with fields
like name, method, action, etc.

For example, using document.forms[0].name to get the name of the form
seems to map to document.forms[0].elements["name"] istead of the
actual name of the form. Is there a work around for this? I am
writing some generic form validation code, and I can't expect the
person implementing my form validation code to avoid using "name" and
"length" as names for their form fields.

View 1 Replies View Related

Add A New Form Hidden Field And Value To An Existing Form?

Jul 22, 2009

I have done this once before but it has been a while. How do I add a new form hidden field and value to an existing form and then submit the form within a function that can be run with an onclick event?

View 3 Replies View Related

Form Text Field/SUBMIT Links To Onsite URL - On Home Page - Text Field And Submit Button ?

Feb 22, 2009

I have a website containing 26 subdirectories 'a' to 'z'

On the home page I want a text field and submit button

If someone for example types 'j' it will go to the 'j' folder home page

Does anyone know where I might find code like this?

View 1 Replies View Related

Clearing Arrays On The Fly

Jul 12, 2005

Have an array l am building up during end user selections. There is an option to clear all selections, how do l then clear the array?

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved