Here is the scenario that unfolded:
Within a .php file, I had the following form:
<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>
Placed just outside the body tag was the following:
<script type="text/javascript" src="/flash_card/js/webscripts.js"></script>
Contained within this file was:
/**
*
*/
function validateForm(){
document.write("IMPRINTED IN YOUR MEMORY");
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 some experimentation, I discovered that my validateForm() function was not triggering at all. Separating it into its own file allowed it to properly fire on click, and the text box's onkeydown event was also functioning correctly.
So where did I go astray? I assumed that a .js file can house multiple functions, so I must be overlooking a basic concept.