如何在jFormer上提交表单时禁用ajax?我只需要将表单提交到另一个php文件/不使用ajax /.
编辑:
jFormer
代码:
// 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->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();
答案 0 :(得分:0)
编辑:
Unbind()可能就是您所需要的
$('#myForm').unbind('submit');
<击> Mebbe简单如:
$('#myForm input[type=submit]').click(function(){
return false;
});
击> <击> 撞击>
我无法让它在jsfiddle中工作,可能是因为它需要的php文件。