In article <O%************ *******@bignews 4.bellsouth.net >, "Mike Irwin"
<mi**@faroutfre akyshit.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="checkO therField()" name="mySubmit" >
function checkOtherField (){
if (!document.some Form.someObject .checked){
document.someFo rm.mySubmit.blu r()
}
}
Or:
<input type="submit" onFocus="
if (!document.some Form.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="retur n checkOtherField ()">
function checkOtherField (){
if (!document.some Form.someObject .checked){retur n false}
else{return true}
}
--
Randy