The onSubmit event handler is not preventing access to the specified site i want it to go to. I don't know if something is wrong with my function or what. For various reasons im leaving out the site name for now, so please dont think thats the issue. Readers please jump down to the last post, that is where i hit road block. Please Help!
</head>
<body>
<hgroup>
<h1>New Artist Application Form</h1>
<h2></h2>
</hgroup>
<p>
</p>
<div style="text-align: center;" valign="middle">
<form name="naform" id="naform" action="THIS IS WHERE THE WEBSITE WOULD USUALLY SHOW UP/BUT I LEFT IT OUT"
method="post"
onSubmit="return checkAllTextBoxes();">
<table border="2" style="border-collapse:collapse;width:40%">
<tr>
<td colspan="2">
if (document.naform.firstname.value.length <= 1) {
alert("First Name too short--must be at least 2 chars");
document.naform.firstname.focus();
document.naform.firstname.select();
return false; // leave now --block submit
}
}
return true; // if made it to here, all OK--let submit proceed
}
More if statements are going to be added, but i cant get the first stipulation to work, to prevent access to the site. It keeps on bypassing my function. Please help as soon as possible, i have a tight deadline, thanks!
function checkAllTextBoxes() {
if (document.naform.firstname.value.length <= 1) {
alert("First Name too short--must be at least 2 chars");
document.naform.firstname.focus();
document.naform.firstname.select();
return false; // leave now --block submit
}
} <<< this bracket is incorrect/spare, causing the code to fail
return true; // if made it to here, all OK--let submit proceed
}
..because my console told me so!
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
Last edited by AndrewGSW; 12-09-2012 at 11:45 PM..
changed and still doesnt deny access to linked page
I changed the curly bracket to face the other way and it still doesnt run the function and deny access to the linked page. thanks for your help, but do you have any other suggestions??NVM you were right thanks a ton!
I changed the curly bracket to face the other way and it still doesnt run the function and deny access to the linked page. thanks for your help, but do you have any other suggestions??NVM you were right thanks a ton!
It is not necessary to turn a bracket the other way before deleting it
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
My string as i interpret it, is saying i have to enter at least five characters whether they are a letter, a number, or a special character, but when i enter just 1 character the function still allows access to the site. What is going on with my password if statement? Someone please help!
This is the JS library file for newArtist.html page
-------------------------------------------------------*/
/*
The purpose of this function is to go thru the new
artist form and check the content of all the
text boxes for validity. Created yyyy/mm/dd by .
*/
function checkAllTextBoxes() {
if (document.naform.firstname.value.length <= 1) {
alert("First Name too short--must be at least 2 chars");
document.naform.firstname.focus();
document.naform.firstname.select();
return false; // leave now --block submit
}
if (document.naform.lastname.value.length <= 1) {
alert("Last Name too short--must be at least 2 chars");
document.naform.lastname.focus();
document.nafofrm.lastname.select();
return false; // leave now --block submit
}
if (/^\w{5,}$/.test(password)) {
}else {
alert("Invalid Password");
return false;
}
return true; // if made it to here, all OK--let submit proceed
}
BTW, when posting here please help us to help you by following the posting guidelines and wrapping your code in CODE tags. This means use the octothorpe or # button on the toolbar. You can (and should) edit your previous post.
__________________
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.