In article <O%*******************@bignews4.bellsouth.net>, "Mike Irwin"
<mi**@faroutfreakyshit.com> writes:
I'd like to prevent a submit button from getting focus unless a particular
textbox or radio button is selected.
For example, if a user clicks anywhere within a form, the submit button is
focused and will submit whatever data is present if the user accidentally
presses Enter/Return. I would like to prevent this from happening unless
the user's cursor is within a textbox or the selection is on a radio button.
Is this possible? I believe this only happens with IE/Win.
<input type="submit" onFocus="checkOtherField()" name="mySubmit">
function checkOtherField(){
if (!document.someForm.someObject.checked){
document.someForm.mySubmit.blur()
}
}
Or:
<input type="submit" onFocus="
if (!document.someForm.someObject.checked){this.blur( )}
" name="mySubmit">
Although, a better all around solution is to use the onSubmit of the form to
check it, instead of focus:
<form name="someForm" onSubmit="return checkOtherField()">
function checkOtherField(){
if (!document.someForm.someObject.checked){return false}
else{return true}
}
--
Randy