Navigation Menu
Alphabetical Listing
Site Contents

Site FAQ
About JSS
JavaScript Forum
JavaScript Tutorial
Friends of JSS

Link to Us
JavaScript Help
Contribute a script
Technology Jobs

Become a Partner

Internet.commerce

Be a Commerce Partner














Internet.com

IT
Developer
Internet News
Small Business
Personal Technology

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


Social Bookmark

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. Do not include more than two (2) lines of code in your comments. If you have suggestions or corrections, you can submit them to us.]

    
   
       
[optional]
 
[optional]

   

Comments feed Comment Feed RSS 2.0

12. From: M Yelverton
Client desired required fields...
11/18/2008 19:59:58

Just what I needed thanks!

11. From: Liz Maher
Enjoyed, made a change
08/05/2008 14:39:19

Thanks for the sript. Because I need my field names to be what they are and not have "required" in front of them, I made a change to the script. I gave each form element an ID of required_xxx where xxx is any prompt - works with spaces and seems much friendlier than the field name.

The only change tot the js file was replacing "name" with "id".

Thanks for the script.

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".

next comments...

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.