javascript help -- easy, please help.. - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Programming > Other Programming - Perl, C++, Java, ASP, .NET Development

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-21-2010, 01:02 PM   #1 (permalink)
Junior Member
 
Join Date: Jan 2010
Posts: 1
Default javascript help -- easy, please help..

this should be easy, but I'm getting Object expected errors. I want to run these two functions on the form submit. I think it's a DOM thing. I had validatePassword working in a standalone test page. somethings getting lost in translation. been writing c++ for five years 'til now, so this is a newbie issue i suspect. if I don't call validatePassword the first block of code works fine. dunno... thanks for any help in advance.

~eric

<script language="Javascript">
<!-- Hide from older browsers
function validatePassword( theForm, helperMsg)
{

var elem = document.getElementByID("newpassword1");
/// elem.value.search returns the position of the first found expression or -1 if not found
var regexAlpha = /[a-zA-Z]+/;
var regexNumeric = /[0-9]+/;
var regexSpaces = /\s/;

var Spaces = elem.value.search(regexSpaces);
var alpha = elem.value.search(regexAlpha);
var numeric = elem.value.search(regexNumeric);

//alert ( "Alpha " + elem.value.search(regexAlpha) );
//alert ( "Numeric " + elem.value.search(regexNumeric) );
//alert ( "Spaces " + Spaces );
//alert ( "userPwd.length " + userPwd.length );

// if has alpha, numeric and no spaces, valid
if( alpha >= 0 &&
numeric >= 0 &&
Spaces < 0 &&
elem.value.length >= 6
)
{
return true;
}
else
{
alert(helperMsg);
return false;
}
}

function ValidateForm(theForm) {
// Validate all of the fields on this form.

//defaults -- set to true if form entries are proper
var allFilled=false;
var validPassword=false;
if (MustEnter(theForm.oldpassword,'Old Password') &&
MustEnter(theForm.newpassword1,'New Password') &&
MustEnter(theForm.newpassword2,'New Password') &&
MustEnter(theForm.firstname,'First Name') &&
MustEnter(theForm.lastname,'Last Name')
) {
allFilled = true;
}
else {
return false;
}

if ( ValidatePassword( theForm, 'Invalid Password') )
{
validPassword = true;
}
else
{
validPassword = false;
}

if( allFilled && validPassword)
{
return true;
}
else
{
return false;
}

} // end of ValidateForm

-->
</SCRIPT>

<form name="distlogin" action="resetPassword.asp" method="POST" onSubmit="return ValidateForm(this);">
ericinSpokane is offline   Reply With Quote
Sponsored Links
Reply

Tags
easy , javascript

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 07:01 PM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting