Solved

Form field validation

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

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 82

Expert Comment

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

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
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…

746 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

11 Experts available now in Live!

Get 1:1 Help Now