javascript - Testing if value is a function -
I need to check whether a form of onsubmit is a function is usually < Code> onsubmit = "valid value ();" . Is there any way to tell if this is a function, and if it is a liability? Using the type, it gives only a string, which does not help me much.
Edit : I understand that "back valid ();" I have changed the to a string d has changed it to "valid ();", and even "valid", I want to know that any of these functions is .
Edit : Here are some code that can help me understand my problem:
$ ("A.button" ) ("A.button") parents ("form"). Submit (function () {var submit_function = $ ("a.button"). Parent ("form"). Attr ("onsubmit"); if (submit_function & amp; amp; amp; amp; amp ; & Amp; amp; amp; amp; amp; amp; amp; type; (submit_function.replace (/ return /, "") == 'function') {return eval (submit_function.replace (/ return /, ""); Else {warning ("a function. \ N \ n what script is included?"); Return back;}}); 2 edited : Here's the new code It appears that I still have to use an eval, because of the call. Does not fire neusmittit.
Since I'm changing a submit button with an anchor link . Submitted () does not activate onsubmit, I am looking for it, but I would like to check whether the function is present before eval only () What is ING there - gms8994
& lt; Script type = "text / javascript" & gt; Function OnSubmit Handler () {Warning ('OnSubmit Handles Moving'); Back true; } Function testOnsubmitAndSubmit (f) {if (typeof f.onsubmit === 'function') {// onsubmit is executable, test return value if (f.onsubmit ()) {// onsubmit returns true, form Submit f. Submit (); }} & Lt; / Script & gt; & Lt; Form name = "theform" onsubmit = "returns onsubmit handler ();" & Gt; & Lt; A href = "#" onclick = "testOnsubmitAndSubmit (document.forms ['theform']); return false;" & Gt; & Lt; / A & gt; & Lt; / Form & gt; EDIT: missing parameter in the Function Testimonials EndSubmit
After this, whether you assign or assign it to onsubmit HTML attribute, javascript :
document.forms ['theform']. Onsubmit = onsubmitandler;
Comments
Post a Comment