EasyUI Forum
November 02, 2025, 06:34:03 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: event when failed submit a form  (Read 9190 times)
Opan Mustopah
Full Member
***
Posts: 164


Indonesia


View Profile Email
« on: February 08, 2015, 08:15:06 AM »

hello again,

is there a way to make a form have a default event for handling when failed submitting?

as far as i can see in documentatio, there is just onSubmit event.

how to make form plugin achieve this feature?

many thanks for the answer.
Logged

-- Bajak Otak --
*** Sorry for my bad english :3 ***
--JeasyUI version 1.4--
jjosotoro
Newbie
*
Posts: 4


View Profile
« Reply #1 on: March 04, 2015, 08:51:54 AM »

Hello

As far I undestand you want to know if there was no answer from server after submiting a form. If thats the case the onSubmit can validate if there was no answer, an error or success.

1. create a function to submit when click on button.
2. check for the answers of the onSubmit.

Code:
function saveProcess(){
    $('#fm').form('submit',{
        url: 'SaveProcess.php',
        onSubmit: function(){
            return $(this).form('validate');
        },
        success: function(result){ // the url must return an answer
    if (result == '') { // if no answer (submit failed)
                $.messager.show({
                    title: 'Error',
                    msg: 'No answer from server'
                });
     } else if (result.replace(/\W/g,'') !== 'OK'){ //if answer is not OK ("error" you can set your own answer)
                $.messager.show({
                    title: 'Error',
                    msg: result,
width:'650',
height:'800',
style:{
right:'',
bottom:''
}
                });
              } else { //the answer is OK.

              $.messager.show({
                title: 'Success',
                msg: 'Process saved',
style:{
right:'',
bottom:''
}
               });

            }
        }
    });
};


I'm not sure if this is what you're asking, but is a way to validate the submiting of a form.

regards
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!