javascript - JQuery Ajax Submit Error Messages Stack -


i have form has required fields. display errors when click continue not enter required fields. if click continue again without entering required fields, previous error message stays, , new 1 created underneath it. should not happen.

now clearified structure , how want work, should work you. remove previous error messages everytime form submitted.

function submit_ajax_form() {   $('.error_span').remove();   // submits form ajax especting json response   $('#usermgmtform').ajaxsubmit({     success: function(response, statustext, xhr) {       if (response['status'] == 'ok') {         window.location.replace(response['location']);       } else {         jquery.each(response['errors'], function(field, errors) {                         jquery.each(errors, function(i, error) {             $fieldid = $('#id_'+field);                             $fieldid.closest('.control-group').addclass('error');             $fieldid.parent().append($('<span class="error_span">').addclass('help-inline').append(error));           })         })       }     }   }) } 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -