简体   繁体   中英

using jquery to return multiple values for my registration form validation

hi i am trying to carry out dynamic checks on my registration form, so when the user enters information, the php code is checking it for errors.currently, i am only trying to pass the values back to jquery to be displayed on the form, i have not yet carried out any validation on the input boxes. i can only seem to pass one value back, as soon as i try and pass multiple values, nothing gets returned, any help would be mostly appreciated.

You should send the whole form if you want to validate multiple inputs at once to your php.

Your validate function should look something like

function validate(fname, lname){
$.post('php/registration.php', $("form").serialize(), function(data){
        $('#fname_feedback').text(data.fname);
        $('#lname_feedback').text(data.lname);
    },'json');
}}

And your php function could be something like (until you do the validation)

$return_data=$_POST;

header('Content-Type: application/json');
echo json_encode($return_data);
exit();

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM