Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


 
 
LinkBack Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 03-13-2006, 09:10 AM   #1 (permalink)
Contributing Member
 
ATLien's Avatar
 
Join Date: 10-13-03
Location: Atlanta, GA
Posts: 1,135
iTrader: 0 / 0%
ATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really niceATLien is just really nice
Send a message via AIM to ATLien Send a message via Skype™ to ATLien
Javascript Form Validation Help

I wanted to know if someone could maybe help me out with some javascript. I have some custom javascript code that was written for me a while back. I wanted to know if someone could make the code form specific.
Code:
i.e. <form method="POST" action="http://www.atliengeorgia.com/..." name="contact" onsubmit="return validateForm("contact");">
I am using this on one page that has 2 forms and when I submit one, it tries to validate both forms. I want it so that the submission of one will only validate the form being submitted.

Thanks alot for the help.
Code:
function validateForm() { return (LJ_checkRequriedFields() && checkEqualGroups()) } function LJ_checkRequriedFields() { var all_filled = true, reqFs = document.getElementsByTagName("INPUT"); var reqTAs = document.getElementsByTagName("TEXTAREA"); var err_string = "Please complete all required and invalid fields\n\nThe following fields are invalid or have been left empty:\n\n"; var first = -1; if (reqFs != undefined && reqFs.length > 0) { for (var i = 0, j = reqFs.length; i < j; i++) { if (reqFs[i].required || reqFs[i].getAttribute('required') != null) { if ((reqFs[i].value.length <= 0) || ((reqFs[i].value.split(" ").length-1) == reqFs[i].value.length)) { reqFs[i].style.border = "double red 3px;"; err_string += reqFs[i].name+"\n"; all_filled = false; if (first < 0) first = i; } else if (reqFs[i].getAttribute('valid') == "email" && !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(reqFs[i].value))) { reqFs[i].style.border = "double red 3px;"; err_string += reqFs[i].name+"\n"; all_filled = false; if (first < 0) first = i; } else reqFs[i].style.border = "solid #7F9DB9 1px"; } } } if (reqTAs != undefined && reqTAs.length > 0) { for (var i = 0, j = reqTAs.length; i < j; i++) { if (reqTAs[i].required || reqTAs[i].getAttribute('required') != null) { if ((reqTAs[i].value.length <= 0) || ((reqTAs[i].value.split(" ").length-1) == reqTAs[i].value.length)) { reqTAs[i].style.border = "double red 3px;"; err_string += reqTAs[i].name+"\n"; all_filled = false; if (first < 0) first = i; } else reqTAs[i].style.border = "solid #7F9DB9 1px"; } } } if (all_filled) return true; reqFs[first].focus(); alert(err_string); return false; } function isEmailAddres(str) { return (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str)) }
ATLien is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript or PHP validation? ATLien Coding Forum 23 04-20-2007 03:53 PM
Your recommended Form Field Validation Javascript bestempire Coding Forum 1 05-30-2006 08:18 AM
Javascript Number Validation imaginemn Coding Forum 1 05-18-2006 07:57 PM
Validation Help / Javascript rodneyj Coding Forum 0 06-23-2004 11:16 AM
Minimum characters in textarea - Form validation Jazzee Coding Forum 15 10-29-2003 11:46 AM


Sponsor Links
Get exposure! Contextual Links V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 06:22 AM.
© Copyright 2008 V7 Inc
Powered by vBulletin
Copyright © 2000-2009 Jelsoft Enterprises Limited.


Search Engine Optimization by vBSEO 3.3.0 ©2009, Crawlability, Inc.