There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot browser bsod computer connection cpu crash css dell desktop driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor network networking outlook outlook 2003 outlook 2007 outlook express password popups problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Combining JavaScript functions


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
juparis's Avatar
Member with 47 posts.
 
Join Date: Jan 2004
Location: In my own dream world
Experience: A Mediocre Genius
02-Aug-2004, 09:54 PM #1
Exclamation Combining JavaScript functions
I have a large sign up page on my website. I'm trying to (using JavaScript) perform the following functions: 1. Check all fields (and prevent submission if blank fields are found) 2. Check that the password is the same in two text fields. 3. Check the same for the email, and check the email format. 4. Prevent multiple submissions.
Since I couldn't find or create a script with all of those functions, I took several different scripts and tried using them on the same page. Sadly, none of them work when I try to use them. Does anyone know why they wouldn't be working, or how to combine them all into one simple script?

I posted the coding I used below...


<script type="text/javascript">

var formerrormsg="Please Wait...\n You've already submitted the form once."

function checksubmit(submitbtn){
submitbtn.form.submit()
checksubmit=blocksubmit
return false
}

function blocksubmit(){
if (typeof formerrormsg!="undefined")
alert(formerrormsg)
return false
}

</script>
<script type="text/javascript">
//<![CDATA[

function toggleField(fieldName, v){
document.getElementsByName(fieldName)[0].style.display = (v)? 'inline' : 'none';
}

//]]>
</script>
<style type="text/css">
/*<![CDATA[*/

.hideme {
display: none;
}

/*]]>*/
</style>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function checkPw(form) {
pw1 = form.pw1.value;
pw2 = form.pw2.value;

if (pw1 != pw2) {
alert ("\nYou did not enter the same password twice. Please re-enter your password.")
return false;
}
else return true;
}
// End -->
</script>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function checkEm(form) {
pw1 = form.email.value;
pw2 = form.f1.value;

if (pw1 != pw2) {
alert ("\nYou did not enter the same email twice. Please re-enter your email.")
return false;
}
else return true;
}
// End -->
</script>
<SCRIPT LANGUAGE="JavaScript">
<!--
function validateForm()
{
var count=0;
var msg="";

for(i=0;i<=4;i++)
{
if(document.UD.elements[i].value=="")
{
count=1;
msg=msg+"\n"+document.UD.elements[i].name;
}
else if((i>3) && (count==0))
{
return(true);
}
}
for(i=0;i<=4;i++)
{
if(document.UD.elements[i].value=="")
{
alert("PLEASE FILL IN THE FOLLOWING FIELD(S)\n "+msg);
document.UD.elements[i].focus();
return(false);
}

}


}
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
function checkEmail(myForm) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.email.value)){
return (true)
}
alert("Invalid E-mail Address! Please re-enter.")
return (false)
}
// End -->
</script>
..........
<FORM METHOD=POST
ACTION="http://www.qkxyq.com/thalasson/mailform.cgi" onsubmit="return (check(this) && checkPw(this) && checkEm(this) && return validateForm() && return checkEmail(this)">


Oh yea, there is one other script in that mess that helps me to toggle a field's visibility, but that still works fine... Thanks for all your help!
__________________
The Original...Juparis

Watch Out for Google! - HTML Forums

Last edited by juparis : 02-Aug-2004 10:20 PM.
juparis's Avatar
Member with 47 posts.
 
Join Date: Jan 2004
Location: In my own dream world
Experience: A Mediocre Genius
04-Aug-2004, 08:00 PM #2
Can anyone find what's wrong? If it helps, you can see my testing page here.
Reply


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

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 Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 12:04 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.