Testando se o valor é uma função

Preciso testar se o valor de @ de um formuláronsubmit é uma função. O formato é tipicamenteonsubmit="return valid();". Existe uma maneira de saber se isso é uma função e se é possível chamar? Usar typeof simplesmente retorna que é uma string, o que não me ajuda muit

EDITA: Claro, entendo que "return valid ();" é uma string. Eu tenhoreplaced até "valid ();" e até "valid ()". Quero saber se uma dessas funções é uma funçã

EDITA: Aqui está um código que pode ajudar a explicar meu 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: Aqui está o novo código. Parece que ainda preciso usar uma avaliação, porque chamar form.submit () não aciona as submissões existente

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;
    }
} );

Sugestões sobre como fazer isso melhor?

questionAnswers(15)

yourAnswerToTheQuestion