开发者

How to disable ajax on jFormer

开发者 https://www.devze.com 2023-02-25 19:48 出处:网络
How can I disable ajax when submit form on jFormer? I just need a submit a form to another php file /not using ajax/.

How can I disable ajax when submit form on jFormer? I just need a submit a form to another php file /not using ajax/.

EDITED:

jFormer

Code:

    // create the form
    $loginForm = new JFormer("loginForm", array('submitButtonText' => 'Sign In', 'action'=>'login_check.php'));

    // Create the form page
    $jFormPage = new JFormPage($loginForm->id.'Page', array('title'=>'<p>Sign In</p>'));

    // create the form section
    $jFormSection = new JFormSection($loginForm->id.'Section');
    $jFormSection->addJFormComponentArray(
        array(
            new JFormComponentSingleLineText("username", "Username:", array(
                'validationOptions'=>array('required', 'username')
                , 'tip' => '<p>Type your <b>username</b>.</p>'
            ))

            , new JFormComponentSingleLineText("password", "Password:", array(
                'type' => 'password'
                , 'validationOptions'=>array('required', 'password')
                , 'tip'=>'<p>Type your <b>password</b>.</p>'
            ))

            , new JFormComponentMultipleChoice('rememberMe', '',
            array(
                array('value' => 'remember', 'label' => 'Keep me logged in on this computer')
            )
                , array('tip' => '<p>If a cookie is set you can have this checked by default.</p>')
        )
        )
    );

    // Add the section to the page
    $jFormPage->addJFormSection($jFormSection);

    // Add the page to the form
    $loginForm->addJFormPage($jFormPage);

    // Set the function for a successful form submission
    function onSubmit($formValues) {
        $formValues = $formValues->loginFormPage->loginFormSection;
        if($formValues->username == 'admin' && $formValues->开发者_StackOverflow中文版password == '12345') {
            if(!empty($formValues->rememberMe)) {
                $response = array('successPageHtml' => '<p>Login Successful</p><p>We\'ll keep you logged in on this computer.</p>');
            } else {
                $response = array('successPageHtml' => '<p>Login Successful</p><p>We won\'t keep you logged in on this computer.</p>');
            }
        } else {
            $response = array('failureNoticeHtml' => 'Invalid username or password.', 'failureJs' => "$('#password').val('').focus();");
        }
        return $response;
    }
    $loginForm->processRequest();


Edit:

Unbind() may be what you need

$('#myForm').unbind('submit');

Mebbe simple as:

$('#myForm input[type=submit]').click(function(){
   return false;
});

I can't get it to work in jsfiddle, probably because of the php file it needs.

0

精彩评论

暂无评论...
验证码 换一张
取 消