Search
The Business Internet

Navigation Menu

Site Contents
What's New?


Site FAQ
About JSS
JavaScript Forum
JavaScript Tutorial
Friends of JSS

Link to Us
JavaScript Help
Contribute a script
Technology Jobs

Internet.commerce

Partner With Us
Home Improvement
Get Business Software
Web Hosting Directory
Promotional Items
Promotional Products
Imprinted Promotions
Calling Cards
Televisions
Desktop Computers
Baby Photo Contest
Hurricane Shutters
KVM Switch over IP
Car Donations
Online Shopping

Internet.com

IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

Developer Channel

FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

Great Sites

DocJavaScript.com
dhtml.com
The Freebie Directory
TheFreeSite.com

Browse Doc JS's Tips!


Hiermenus Central


Promotions

Free Announcements


General

This is a simple method to require your visitors to fill out certain fields in a form. Just add the word "required" to each required field's name and your visitor must fill it out to submit the form.


Name:
E-mail:
Comments:

Notes

Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: basicValidation.js


Head

Paste this code into the HEAD section of your HTML document.


Body

Paste this code into the BODY section of your HTML document


User Comments

Add a comment, suggestion, or correction
[For questions about usage, consult the Notes tab above or visit the JavaScript forum]

    
   
       
[optional field]
 
[optional field]

   

Comments feed Comment Feed RSS 2.0

10. From: db
Basic Validation -- Slight Modification :-)
06/18/2008 17:48:29

If you don't want to change the name of the field, you can use the basic validation script on the "ID" tag instead. Here are the changes to the basicValidation script:

...
if (tempobj.id.substring(0,8)=="required") {
... shortFieldName=tempobj.id.substring(8,30).toUpperCase();


Inside of the HTML tag:

<input id="requiredLogin Name" type=text name="Login_Name" value="">

HAVE FUN and thanks for the basicValidation script!!!

7. From: archi
Simple & great
10/16/2007 10:39:52

Easy to implement and to change to add check boxes and similar stuff.

6. From: Deepak kumar.d
Excellent Code
10/04/2007 07:00:06

Great,
Thank you for giving me a such a valuable code. I will make use of this code to develop my web page.

8. From: Aju John
Help add my email to this script!
10/01/2007 03:43:00

Sir,
i am a novice in script. I wanted to add my email id to this script so that it goes to my mail ID when Submit is pressed. Plz help.
Regards,
Aju John.

9. From: Lee (Admin)
11/06/2007 11:58:07

This script for for validation purposes only. You will need to find a different type of script for that.

4. From: MK
Good but email validation is MISSING
09/06/2007 10:03:29

Good but email validation is MISSING
one must be able to validate email@domain.com

5. From: Lee (Admin)
10/03/2007 15:40:35

Yep, that's why it's called "basic". We have other scripts that do that in great deatil.

3. From: Raphael
07/24/2007 14:35:49

I'm trying to use this togheter with Formmail. The scrypt does everything right, but when everything is working fine, and validade all fields, instead of executing my formmail.pl, it's actually trying to access "your.host.com".

1. From: Jaiyakar
suggestion regarding the basic validation java script.
05/26/2007 00:33:56

Hi....
The java script you have on this website for basic validation works fine....it makes sure that the user always enters some data in that field....But the user can skip the field by just pressing the space bar once and can submit the form.....

Can you help me with a source code(java script) to overcome this poblem.....

2. From: Agus Ariyanto
06/06/2007 04:34:33

You can combine it with some stripspace script. You can get it at this site.


Do you write JavaScripts?
If you do, why not submit them to us?
We'll give you credit and a link back to your Web site.