The situation was as follows:
I had this form in a .php file:
<form action="/flash_card/scripts/create_user_gate.php"
onsubmit="return validateForm()" method="post">
<table align="center">
<tr>
<td>Name</td>
<td><input type="text" name="name" id="uname"
onkeydown="return checkInput(event)"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password">
</tr>
<tr>
<td></td>
<td><button onclick="return validateForm()" type="button"
title="Create user!" name="submit">Create!</button>
</td>
</tr>
</table>
</form>
With this just outside the body tag:
<script type="text/javascript" src="/flash_card/js/webscripts.js"></script>
This file contained:
/**
*
*/
function validateForm(){
document.write("BURNED INTO YOUR MINDDDD");
return false;
}
function onlyAlphaNumericAndModifiers(e) {
var keynum;
var keychar;
var numcheck;
if (window.event) // IE
{
keynum = e.keyCode;
} else if (e.which) // Netscape/Firefox/Opera
{
keynum = e.which;
}
// letters, numbers, backspace, delete, arrow keys
if (keynum >= 65 && keynum <= 90 || keynum >= 48 && keynum <= 57
|| keynum == 8 || keynum >= 37 && keynum <= 40 || keynum == 46) {
return true;
} else {
return false;
}
}
After fiddling around, I find that I cannot get my validateForm() to fire at all, so I separate it into its own file and suddenly on the click fires validateForm() properly and the text box’s onkeydown is firing checkInput correctly as well.
Where did I go wrong? I am assuming that a .js file can contain more than one function, so I must be missing something fundamental.
It seems like you may have an error in /flash_card/js/webscripts.js, can you post the source of this file?