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


ADVERTISEMENT

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

JQuery :: Clearing Fields In Div?

Jun 9, 2009

how can i clear the feilds in using jquery just like reset form in html.

View 4 Replies View Related

Clearing Input Fields

Jun 2, 2005

I have a form with two input fields - 'name' & 'research'. What I'd like is for 'name' to be cleared when the user clicks in 'research' & visa versa. I've tried to do this by implementing the code in Sitepoint's excellent new DHTML Utopia article, but without success. I'm guessing that I should be using the onblur event, but am not sure how to go: Code:

View 3 Replies View Related

Clearing Two Popups And Text Fields On Checkbox Selection Not Working In Ie7

Mar 6, 2009

why isn't this working ok in ie7?:

[URL]

the javascript is:

Code:
<script type="text/javascript">
/* <![CDATA[ */
function closed_changed(day) {

[Code].....

it should call closed_changed(), which sees if it's ticked/checked, if it is it calls clear_open() and sets the four open related input elements to empty/blank (because a shop can't be open and closed at the same time). works fine in firefox (pc and mac) and safari. not ie7. why not? (the intended clear does happen but only when another subsequent closed box is ticked; it works on the previous day which was ticked; so it's lagging one behind)

View 2 Replies View Related

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 View Related

JQuery :: Form Validation - Two Input Fields In A Form - Only One Of Two Fields Is Required

Oct 10, 2009

There are two input fields in a form, but only one of them is required, they are not required at the same time. Either A or B is required. ( A is required OR B is required). In other words, a user can input data to field A, or he can input data to filed B, but he can not input data to Both A and B at the same time. How to implement this constraint in Jquery form validation?

View 17 Replies View Related

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

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

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

Add And Delete Form Fields BUT A Textarea Or A Section Of Input Fields

Oct 11, 2006

I have been looking for the past 2 days for a script that I can add and delete table rows.

I have found a lot but so far all of them add an input field but I desperatly need a textarea or ideally a section of input fields.

I have tried to change the code from input to text area but none of them worked.

Have you come across to a similar script.

I would appreciate any contributions.

What I am trying to do is a page where the user will add their employees details so we can order business cards for them. So I have fileds such as, Name, Tel Num, Email, Cell etc.

View 4 Replies View Related

Order Form Change Text Fields With Select Fields

Jan 24, 2011

I have this order form where the customers can change the quantity by intput in a text field.I would like to have the text field changed with select fields, but doing so in the form, the script is not doing anymore.Can anyone have a look and tell me what to change in the scritp to accept select fields in place of the text fields.

View 5 Replies View Related

Document.form.submit() Doesn't Work For Large Form Fields

Mar 2, 2006

I am having a problem with the submit() method that is driving me nuts. I'm using document.form.submit() with large text fields (approx. 2000 characters) and am getting a "Invalid Syntax" error. If I do the same thing with a text field of under 1500 characters, it works fine.

Is there some size limit here that I don't know about?

View 2 Replies View Related

Form Validation Script - Stop Sending The Form If Key Fields Are Missing

Aug 13, 2011

Having a few problems with a form validation script. Its supposed to stop sending the form if key fields are missing, but it just sends them anyway!

Below is the code i use in the header to check for blank fields:

Code:

And now the code i use to action it:

Code:

From what i can see the fields match, it all links up correctly but still it will allow blank forms to be sent.

View 3 Replies View Related

JQuery :: Malsup's Form Plugin Uses .attr() For Disabled - IE7 Drops Form Fields W/ JQ Core 1.6.*?

Jul 11, 2011

We're using Malsup's form plugin v2.82 and jQuery core 1.6.2. We're having issues in IE7 where, on a form with file upload, form fields are being dropped before the form is submitted to the server.We tracked it down to the `fileUpload` function, specifically line 196 where each field in the form data has `.attr('disabled',false)` run against it. If we change this to`.prop('disabled',false)` it all works fine.I don't see a clearly marked place to submit bug reports for the form plugin, and wanted to verify that others see this as well,

View 6 Replies View Related

CSS And Form Validation - Changing The Font Color Of Labels ONLY When Stop The Form From Submitting Due To Blank Fields

Nov 2, 2011

I'm having trouble changing the font color of my labels ONLY when I stop the form from submitting due to blank fields. I'm not sure whether if just changing my CSS will achieve what I want, or am I going to have to add somethig to my if else statement, or both? I would think I would need to change CSS to :

label.onfocus {
color:red;
}

but a little confused on what else.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
[Code]...

View 21 Replies View Related

The Mootool Adds The Pop Out Effect To A Form Box And The Enables The Nav Switch For 2 Boxes That Contain Different Form Fields For A Search Engine?

Sep 10, 2010

I have two js scripts running on my project at the moment, one is uses mootools and the other uses jquery-1.2.3min, both work but not if they are on the same page.The mootool adds the pop out effect to a form box and the jquery enables the nav switch for 2 boxes that contain different form fields for a search engine. Now I've been reading up on the two and have decided to favour jquery which means I have to reproduce the same effect in mootool but with my limited knowledge it's proven rather hard.The mootool code:

var isExtended = 0;
var height = 165;
var width = 240;

[code]....

View 3 Replies View Related

JQuery :: Form Fields - Keep The Form From Remembering Past Input?

Jun 17, 2011

I have a form that has a reset button, and when it's closed, the form is reset. However, at least in testing on my own machine, I notice that the form fields are remembering past input (on Firefox 4 anyway). Once this goes public, I don't want the form remembering anything in case the website is viewed on a public machine. How can I keep the form fields from remembering any past input?

View 2 Replies View Related

Form Validation Query - Adding Extra Fields To A Form?

Sep 1, 2009

I have a working contact form with 3 of the fields requiring validation and they work well. I have added extra fields to the form (StatusClass, Project, CameFrom). These 3 fields return fine but I need to validated them. My problem is that the new fields don't show in the behaviours/validate panel even though they are within the form tag.

<script type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

[Code]...

View 9 Replies View Related

JQuery :: Run PHP Script After 4 Form Fields Entered And Form Not Submitted?

Nov 12, 2010

I am re-developing my website and want to use some Ajax/jQuery in it (so I am learning as I go) and I am not sure if this is possible so that is my first question:I have a registration form and I would like to know if after the person registering has completed their first and surname and the 2 sections of their postcode if I can use jQuery to run a PHP script to see if they are already registered before waiting for the form to be submitted and running a script then.I am thinking onkeyup (or similar) after the last field is completed but I don't know how that would work needing to also use 3 other field values.If this is possible, can anyone give me any ideas of examples that do this or how I can go about passing all the variables and running the scripts at the correct time.

View 6 Replies View Related

Using Ultimate Form Validator But Form Is Still Submitting Even Though It Says Which Fields Are Missing

Jun 16, 2010

I am using the ultimate form validator [URL] but the form is still submitting even though it says which fields are missing..

View 2 Replies View Related

Form And - Many Form Fields - Input Text ?

Jun 18, 2009

I have a form and there are many form fields, is anyone know how to make one of my input text only for display purpose, not for input.

View 1 Replies View Related

New Form Fields With JS?

Oct 22, 2009

I'm new to here and JS but I have question for you! So I have this form with inputs that are considered arrays in my PHP code:

<input type="checkbox" name="1" /> <input name="i[]" type="text"> <br />
<input type="checkbox" name="2" /> <input name="i[]" type="text"> <br />
<input type="checkbox" name="3" /> <input name="i[]" type="text"> <br />
<input type="checkbox" name="4" /> <input name="i[]" type="text"> <br />

[Code]...

I don't want to keep adding in new spots every time a user want to add a new field. I would like them to be able to press a button that will add another one of those fields and so on. I'm not sure how this can be achieved but that's why I am turning to you!

View 3 Replies View Related

How To Add More Form Fields

Jun 28, 2010

i have this code that generate 10 rows with form fields:

<form>
<?php for($i=1;$i<=10;$i++) {?>
<div id="rowz-rep">
<div class="row1"><?=$i?></div>
<div class="row2a"><input name="title[]" type="text" class="fieldSubmit"/></div>
<div class="row3a"><input name="url[]" type="text" class="fieldSubmit"/></div>

[Code]...

View 1 Replies View Related







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