Solved

Form field validation

Posted on 2014-04-18
3
177 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
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…

895 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now