Solved

Form field validation

Posted on 2014-04-18
3
178 Views
Last Modified: 2014-04-18
I'm trying to create a contact form at www.mauitradewinds.com/RezEasy/contact.html    There is javascript which reminds the visitor to complete four required form fields before submitting the form.  The last required field is "message", but entering a message doesn't satisfy the validator, which pops up an alert.

I'd appreciate guidance on two items:
1. Getting the validator to accept a message; and
2. Changing the alert popup so that it is more informative.
0
Comment
Question by:ddantes
  • 2
3 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 300 total points
ID: 40009724
You can't check a 'textarea' with just 'form.message.value.length'.  I think your syntax is wrong.  In my working pages, I use something like "document.forms.EmailForm.message.value.length".

Some info here also: http://www.w3schools.com/jsref/coll_doc_forms.asp

YOu can also use the 'id' to check it and this is what I use on another page.
function checkit() {
        tx = document.getElementById("tarea").value
        txl = tx.length;
				form.message.value.length==0
        alert(tx+" is "+txl+" chars long.");
        if(txl<4) return false;
}

Open in new window

0
 

Author Comment

by:ddantes
ID: 40009954
Thank you.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40010015
You're welcome, glad to help.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question