Prueba si el valor es una función

Necesito probar si el valor de un formulario esonsubmit es una función. El formato es típicamenteonsubmit="return valid();". ¿Hay alguna manera de saber si esta es una función y si es invocable? Usar typeof simplemente devuelve que es una cadena, lo que no me ayuda mucho.

EDITA: Por supuesto, entiendo que "return valid ();" es una cuerda Hereplaced hasta "valid ();" e incluso "valid ()". Quiero saber si alguno de esos es una función.

EDITA: Aquí hay un código, que puede ayudar a explicar mi problema:

$("a.button").parents("form").submit(function() {
    var submit_function = $("a.button").parents("form").attr("onsubmit");
    if ( submit_function && typeof( submit_function.replace(/return /,"") ) == 'function' ) {
        return eval(submit_function.replace(/return /,""));
    } else {
        alert("onSubmit is not a function.\n\nIs the script included?"); return false;
    }
} );

EDIT 2: Aquí está el nuevo código. Parece que todavía tengo que usar una evaluación, porque llamar a form.submit () no activa los envíos existentes.

var formObj = $("a.button").parents("form");
formObj.submit(function() {
    if ( formObj[0].onsubmit && typeof( formObj.onsubmit ) == 'function' ) {
        return eval(formObj.attr("onsubmit").replace(/return /,""));
    } else {
        alert("onSubmit is not a function.\n\nIs the script included?");
        return false;
    }
} );

Sugerencias sobre posiblemente cómo hacerlo mejor?

Respuestas a la pregunta(15)

Su respuesta a la pregunta