HTML, JavaScript And CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingHTML, JavaScript And CSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 21st, 2004, 07:28 AM
danosullivan danosullivan is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 9 danosullivan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 10 sec
Reputation Power: 0
javascript prob

Can anybody help me out with this script?
It seems to run as far as checking the first name text box and then it just submits the form even if the text box is blank!

Heres the code:
<SCRIPT language = "Javascript" type="text/javascript">

<!-- hide script from older browsers

function validate() {

//checks MOBILE NO to make sure it has a valid number filled in

if(document.frmRegister1.txtMobileNo.value.length < 10)

{

alert('Please fill in Mobile Phone Number.');

document.frmRegister1.txtMobileNo.focus();

return false;

}



//Makes Sure a password of > 6 characters is entered

if(document.frmRegister1.txtPassword.value == '' || document.frmRegister1.txtPassword.value.length < 6)

{

alert("Please enter a password 6 characters or more in length!");

document.frmRegister1.txtPassword.focus();

return false;

}



//Passwords must be the same

if(document.frmRegister1.txtPassword.value == document.frmRegister1.txtPassword2.value)

{

return true;

}

else

{

alert("Passwords must be the same!");

document.frmRegister1.txtPassword.focus();

return false;

}

//Makes sure a FIRST Name is entered

if(document.frmRegister1.txtFirstName.value == '')

{

alert("Please enter your First Name");

document.frmRegister1.txtFirstName.focus();

return false;

}

//Surname

if(document.frmRegister1.txtSurname.value == "")

{

alert("Please enter your Surname");

document.frmRegister1.txtSurname.focus();

return false;

}



//ok to here!!--------------------

//Ensures Passwords are the same



//Ensures Email Passwords are the same

if(document.frmRegister1.txtEPassword.value == document.frmRegister1.txtEPassword2.value)

{

return true;

}

else

{

alert("Email Passwords must be the same!");

document.frmRegister1.txtEPassword.focus();

return false;

}





//Address1

if(document.frmRegister1.txtAddress1.value == "")

{

alert("Please enter your address");

document.frmRegister1.txtAddress1.focus();

return false;

}



//Address2 confirmation

if(document.frmRegister1.txtAddress2.value == '')

{

if(!confirm("Are you sure you want to leave Address 2 blank?\n Hit 'ok' to continue, or hit 'cancel' to go back and make changes."))

{

document.frmRegister1.txtAddress2.focus();

return false;

}

}

}

//-->

</SCRIPT>


Reply With Quote
  #2  
Old February 21st, 2004, 10:29 AM
dcarva's Avatar
dcarva dcarva is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 633 dcarva User rank is Lance Corporal (50 - 100 Reputation Level)dcarva User rank is Lance Corporal (50 - 100 Reputation Level)dcarva User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 9 h 18 m 20 sec
Reputation Power: 6

Reply With Quote
  #3  
Old February 26th, 2004, 03:08 AM
dhaka2k's Avatar
dhaka2k dhaka2k is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 2 dhaka2k User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Arrow

Change the point i colored on your code ... to ""
may be it'll do..
//Makes sure a FIRST Name is entered

if(document.frmRegister1.txtFirstName.value == '')

{

alert("Please enter your First Name");

document.frmRegister1.txtFirstName.focus();

return false;

}

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingHTML, JavaScript And CSS Help > javascript prob


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway