Mike Waller
asked on
javascript validation using cfform
I have the following but it doesn't work properly. It still submits. it should pull up the alert but not submit the form data. any ideas?
<script language="JavaScript" type="text/javascript">
function validatePassword() {
{
if (document.changepwd.newPassword.value != document.changepwd.confirmPassword.value)
alert("Your new passwords must match. Please try again.");
return false;
}
return true;
}
</script>
<cfform name="changepwd" action="" method="POST" onsubmit="validatePassword()">
<div class="">Username: <cfinput type="Text" name="username" validateat="onSubmit" message="You must enter a valid username." validate="email" autosuggestminlength="8" required="Yes" visible="Yes" enabled="Yes" showautosuggestloadingicon="True" typeahead="No" maxlength="50"></div>
<div class="">New password: <cfinput type="Text" name="newPassword" validateat="onSubmit" message="You must enter a valid password." maxlength="16" required="Yes" visible="Yes" enabled="Yes" showautosuggestloadingicon="True" typeahead="No"></div>
<div class="">Confirm password: <cfinput type="Text" name="confirmPassword" validateat="onSubmit" message="You must enter a valid password." maxlength="16" required="Yes" visible="Yes" enabled="Yes" showautosuggestloadingicon="True" typeahead="No" onchange="javascript:window.alert(form.newPassword.value + ' ' + form.confirmPassword.value);"></div>
<cfif isDefined("form.submit")>
do something..
</cfif>
</cfform>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
how can I also ensure that the password field is equal or more than 6 characters using cfform?
How can we ensure this question will not get additional questions appended?
Open in new window