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);">
|