Solved

Form field validation

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

828 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