Script for validating online forms

Script for validating online forms

As long as elem.value.length isn't 0 then it's not empty and we return true, otherwise we send an alert to the user with a helper Msg to inform them of their error and return false.

Remember to check out Tizag's HTML forms lesson if you need to brush up on your form knowledge.

You want to be sure that your visitors enter data into the HTML fields you have "required" for a valid submission.

Below is the Java Script code to perform this basic check to see if a given HTML input is empty or not.

Web Tutorials Beginner Tutorial HTML Tutorial CSS Tutorial Scripting Javascript Tutorial PHP Tutorial Perl Tutorial Ajax Tutorial ASP Tutorial VBScript Tutorial Databases SQL Tutorial My SQL Tutorial Miscellaneous XML Tutorial Webhost Tutorial Flash Tutorial SEO Tutorial Javascript Tutorial Javascript - Intro Javascript - Syntax Javascript - Enable Javascript - Location Javascript - External Javascript - Operators Javascript - Variables Javascript - Functions Javascript - Events Javascript - Statements Javascript - If Javascript - Else If Javascript - While Javascript - For Loop Javascript - Comments Javascript - Array Javascript - Alert Javascript - Confirm Javascript - Prompt Javascript - Print Javascript - Redirect Javascript - Pop Up Javascript - Date Javascript - Void 0 Javascript String Javascript - Strings Javascript - Length Javascript - Split Javascript - Search Javascript - Replace Javascript - index Of Javascript - Compare Javascript Advanced Javascript - get Element By Id Javascript - inner HTML Get Help!

Javascript Forum There's nothing more troublesome than receiving orders, guestbook entries, or other form submitted data that are incomplete in some way.

Java Scriptstrings have built in properties, one of which is the length property which returns the length of the string.

script for validating online forms-29script for validating online forms-58script for validating online forms-67

The chunk of code elem.value will grab the string inside the input and by adding on length elem.value.length we can see how long the string is.

Join our conversation (8 Comments).
Click Here To Leave Your Comment Script for validating online forms.


  1. 1

    Our new fine middle eastern bakery is located at 1415 Kennedy Road Unit #26 (SE corner of Kennedy & Ellesmere).

  2. 1

    Once considered a realm inhabited only by the socially awkward, online dating is now just another tool in the toolbox, no matter whether you’re looking for a hook-up or your soulmate.....

  3. 1

    “It wasn’t that I was specifically attracted to ,” Millie clarified recently.

  4. 1

    For special requests, call the day before and we'll order what you want.

Leave a Reply

Your email address will not be published. Required fields are marked *