By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,384 Members | 1,794 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,384 IT Pros & Developers. It's quick & easy.

Validate password characters

P: 1
Hi, I am new to JavaScript and I am trying to control New Password fields. These fields are not allowed to except any symbols, especially @ / \. The current code I've is not working at all. Could someone help please.


function changepass_submit()
{
if (document.Eform.USERNAME.value=="") {
alert("Please Enter Value for Username");
document.Eform.USERNAME.focus();}
else if (document.Eform.PASSWORD.value=="") {
alert("Please Enter Value for Password");
document.Eform.PASSWORD.focus();}
else if (document.Eform.NEW_PASSWORD.value=="") {
alert("Please Enter Value for New Password");
document.Eform.NEW_PASSWORD.focus();}
else if (document.Eform.NEW_PASSWORD.value=="@" || document.Eform.NEW_PASSWORD.value=="/" || document.Eform.NEW_PASSWORD.value=="&" || document.Eform.NEW_PASSWORD.value=='"') {
alert("Please Enter Value for New Password");
document.Eform.NEW_PASSWORD.focus();}
else if (document.Eform.CONFIRM_PASSWORD.value=="") {
alert("Please Enter Value for Confirm Password");
document.Eform.CONFIRM_PASSWORD.focus();}
else if (document.Eform.CONFIRM_PASSWORD.value!=document.E form.NEW_PASSWORD.value) {
alert("Please Re-enter New Password/Confirm Password...New Password is not the same as Confirm Password");
document.Eform.CONFIRM_PASSWORD.focus();}
else
{ document.Eform.submit() }
}
</script>

Many thanks.
Sep 21 '06 #1
Share this Question
Share on Google+
1 Reply


10K+
P: 13,264
Hi, I am new to JavaScript and I am trying to control New Password fields. These fields are not allowed to except any symbols, especially @ / \. The current code I've is not working at all. Could someone help please.


function changepass_submit()
{
if (document.Eform.USERNAME.value=="") {
alert("Please Enter Value for Username");
document.Eform.USERNAME.focus();}
else if (document.Eform.PASSWORD.value=="") {
alert("Please Enter Value for Password");
document.Eform.PASSWORD.focus();}
else if (document.Eform.NEW_PASSWORD.value=="") {
alert("Please Enter Value for New Password");
document.Eform.NEW_PASSWORD.focus();}
else if (document.Eform.NEW_PASSWORD.value=="@" || document.Eform.NEW_PASSWORD.value=="/" || document.Eform.NEW_PASSWORD.value=="&" || document.Eform.NEW_PASSWORD.value=='"') {
alert("Please Enter Value for New Password");
document.Eform.NEW_PASSWORD.focus();}
else if (document.Eform.CONFIRM_PASSWORD.value=="") {
alert("Please Enter Value for Confirm Password");
document.Eform.CONFIRM_PASSWORD.focus();}
else if (document.Eform.CONFIRM_PASSWORD.value!=document.E form.NEW_PASSWORD.value) {
alert("Please Re-enter New Password/Confirm Password...New Password is not the same as Confirm Password");
document.Eform.CONFIRM_PASSWORD.focus();}
else
{ document.Eform.submit() }
}
</script>

Many thanks.

use regular expressions
Sep 21 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.