Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 186
  • Last Modified:

Form field validation

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
ddantes
Asked:
ddantes
  • 2
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
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
 
ddantesAuthor Commented:
Thank you.
0
 
Dave BaldwinFixer of ProblemsCommented:
You're welcome, glad to help.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now