[thelist] Stop posting from fields (was: Can't submit form data with 'enter' key in IE)
VOLKAN ÖZÇELİK
volkan.ozcelik at gmail.com
Wed Mar 15 01:22:30 CST 2006
2006/3/15, Bill Moseley <moseley at hank.org>:
>
> Thanks. Good points. Not really related to my question, but words
> to live by, no doubt.
Welcome.
> <form onsubmit="return false;">
> >
> > will sort it out.
>
> I still don't follow that suggestion. That prevents all form
> submissions. No wonder you don't recommend it.
Not actually. You can use it along with a codebehind.js
Page.php:
<form onsubmit="return false;">...
Page.js:
window.onload=function(evt)
{
var objForm = document.forms[0];
objForm.onsubmit= Form_submit;/* or use a precooked EventHandler
object of your choice */
};
function Form_submit(evt)
{
var obj = new EventObject(evt);/* a cross-browser wrapper around the
event model */
var src = obj.getSource();
if(src.nodeName.toLowerCase()=="input") && src.id == "whatever)
{/* other controls as necessary*/
obj.cancelDefaultAction();
}
//if the above if is not entered submit action is not cancelled and the
form is submitted
//normally.
};
HTH,
--
Volkan Ozcelik
+>Yep! I'm blogging! : http://www.volkanozcelik.com/volkanozcelik/blog/
+> My projects/studies/trials/errors : http://www.sarmal.com/
More information about the thelist
mailing list