Shrimp007 / rapid-framework

Automatically exported from code.google.com/p/rapid-framework
0 stars 0 forks source link

校验以后,提交之前,怎么把自己的js代码执行呢? #31

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
<script>

    new Validation(document.forms[0],{onSubmit:true,onFormValidate : 
function(result,form) {
        var finalResult = result;
        return disableSubmit(finalResult,'submitButton');

        document.forms[0].j_username.value = document.forms
[0].orgId.value+"~###~"+document.forms[0].j_username.value;

    }});
</script>

 我想在校验以后,把两个域的值相加传到后面,不知道怎么实现呢?谢谢!!!

你使用的相关插件组合是什么?

你还可以在此后面增加其它任何详细信息.

Original issue reported on code.google.com by wfu...@gmail.com on 15 Dec 2009 at 9:04

GoogleCodeExporter commented 9 years ago
你在return之间,编写你自己的代码不就行了。
并且你可以修改finalResult的值,改为false表单就不会提交了。

Original comment by bad...@gmail.com on 15 Dec 2009 at 9:08

GoogleCodeExporter commented 9 years ago
badqiu, 你好, 回复的好快,谢谢

目前是这样:

    new Validation(document.forms[0],{onSubmit:true,onFormValidate : function
(result,form) {
        var finalResult = result;
        alert(result);

    //  return disableSubmit(finalResult,'submitButton');

        return addOrgIdUserName();

    }});
    function addOrgIdUserName(){
    document.forms[0].j_username.value = document.forms
[0].orgId.value+"~###~"+document.forms[0].j_username.value;
    document.forms[0].submit();

    }

Original comment by wfu...@gmail.com on 15 Dec 2009 at 9:25

GoogleCodeExporter commented 9 years ago
最终参考了 
badqiu的代码,很好。很强大! 谢谢
<script>

    new Validation(document.forms[0],{onSubmit:true,onFormValidate : function
(result,form) {
        var finalResult = result;
        return addOrgIdUserName(finalResult,'submitButton');

    }});
    //提交前,把机构号和用户名整合,可做类似参考做为校验后的自定义功能
    function addOrgIdUserName(finalResult,submitButtonId) {
    if(finalResult) {
        document.forms[0].j_username.value = document.forms
[0].orgId.value+"~###~"+document.forms[0].j_username.value;
        document.getElementById(submitButtonId).disabled = true;
        return finalResult;
    }else {
        return finalResult;
    }
}

</script>

Original comment by wfu...@gmail.com on 15 Dec 2009 at 9:46

GoogleCodeExporter commented 9 years ago
Fixed

Original comment by bad...@gmail.com on 18 Dec 2009 at 6:31