There is a form:

<div id="text_error_regform"></div> <div class="registration_form"> <form method="post" action="index.php?route=action/registration" class="form_data"> <div class="form-group"><input type="text" name="name" id="name" class="form-control" placeholder="<?=$data['form_name_text']?>" /></div> <div class="form-group"><input type="text" name="lastname" id="lastname" class="form-control" placeholder="<?=$data['form_lastname_text']?>" /></div> <div class="form-group"> <div class="user_type"> <input type="radio" name="user" value="privat" /> <span class="radio_user"><?=$data['form_privat_radio']?></span> <input type="radio" name="user" value="giuridica" /> <span class="radio_user"><?=$data['form_giuridica_radio']?></span> </div> </div> <div class="form-group"><input type="text" name="iva" class="form-control" id="iva" style="display: none;" placeholder="<?=$data['form_iva_text']?>" /></div> <div class="form-group"><input type="email" name="email" class="form-control" id="email" placeholder="E-mail ..." /></div> <div class="form-group"><input type="text" name="login" class="form-control" id="reglogin" placeholder="<?=$data['form_login_text']?>" /></div> <div class="form-group"><input type="password" name="pass" class="form-control" id="regpass" placeholder="<?=$data['form_pass_text']?>" /></div> <div class="form-group"><input type="text" name="mobile" class="form-control" id="mobile" placeholder="<?=$data['form_mobile_text']?>" /></div> <div class="form-group"><input type="text" name="town" class="form-control" id="town" placeholder="<?=$data['form_town_text']?>" /></div> <div class="send"><input type="submit" name="register_user" value="<?=$data['btn_register']?>" /></div> </form> </div> 

Server data handler:

 private function RegistrationUser($params) { require $this->language->getLanguage('messages'); if ($params['login'] == "" or !$this->valid->validLogin($params['login'])) $message = $lang['message_error_login']; if ($params['pass'] == "") $message = $lang['message_error_pass']; if ($params['name'] == "" or !$this->valid->isOnlyLetters($params['name'])) $message = $lang['message_error_name']; if ($params['lastname'] == "" or !$this->valid->isOnlyLetters($params['lastname'])) $message = $lang['message_error_lastname']; if (!isset($params['user'])) { $message = $lang['message_error_user']; } else { if ($params['user'] == "giuridica") { $message = $lang['message_error_iva']; } else { $params['iva'] = '0'; } } if($params['email'] == "" or !$this->valid->validEmail($params['email'])) $message = $lang['message_error_email']; if($params['town'] == "" or $this->valid->isOnlyLetters($params['towm'])) $message = $lang['message_error_town']; if($params['mobile'] == "" or !$this->valid->isOnlyNumbers($params['mobile'])) $message = $lang['message_error_mobile']; if (isset($message)) return $message; else return true; } 

And there is ajax (which was supposed to be universal, but I see that it is not universal):

 $(document).ready(function() { $('.form_data').on('submit', function(e){ e.preventDefault(); var $that = $(this), fData = $that.serialize(); $.ajax({ url: $that.attr('action'), type: $that.attr('method'), data: {form_data: fData}, dataType: 'json', success: function(json){ if(json.Error) { document.getElementById('text_error_form').innerHTML = json.Error; } else if(json.Success != null) { $('#text_error_form').remove(); $('.form_data').replaceWith(json.Success); } } }); }); }); 

What I want to achieve but fails:
When the user fills in the registration form to check in real-time (keyup) the name field, lastname , when the user selects a radiobox of the type giuridica , then the iva field should appear (it is hidden by default) and also the real-time check for fullness. Same email check. If the mail is entered correctly, you should immediately send an email with the activation number to this address and below there will be a field in which the user will insert this number and, in real time, confirm his address. After that, a simple check of the remaining fields is also in real time.

On php it all works. Help make it to javascript

    1 answer 1

    Maybe jQuery Validator will help you.
    You post it on the form to verify the entered data.

    Letters do not always reach quickly, so you do not need to add a field in your form with a code entry. Better link in the letter for confirmation

    • I do not want to use plugins, help finish the job, otherwise we will never learn anything like that! - privetsh
    • @privetsh What's your problem then? JQuery has keyup , change handlers, you can hang them on these fields, just email and check all this data - Farkhod Daniyarov
    • It is possible an example because I only study all this - privetsh