In answer to your questions...
The keydown or keypress events can
be intercepted before text is input
using javascript
You can return false after binding a
function to the keydown or keypress
event. This will prevent the text
from being input.
Example using jQuery:
$("#inputfield").live("keydown", function(){
return false;
});
If you want to test some input for value on form submit you can do that using jQuery submit().
$("#theform").submit(function() {
var formval = $("#theinput").val();
if(formval == "") { //or some better test
alert("input value"); //or some other alert...
return false;
} else {
return true;
}
});
Returning false will invalidate the click to submit the form.
Edit:
If as you say in your comments you want to disable the submission of the form until requirements are met for the input field(s)
$("#inputfield").live("keyup", function(){
if($("#inputfield").val() == "") {
$('#button').attr("disabled", true);
} else {
$('#button').attr("disabled", false);
}
});
You want to use the "keyup" event handler to allow the text to be sent first. see my example: on jsbin