Answer the question
In order to leave comments, you need to log in
AJAX problem, why doesn't validation work?
Shalom everyone, my head already hurts, I can’t understand what’s wrong, why it doesn’t work
The whole point ... enter the code, if it’s correct, we get a message, if not, then repeat (it seems everything is simple), but I have an inpat check in the code on jquery:
$('input#InputUpVerCode').keyup(function(){
var id = $(this).attr('id');
var val = $(this).val();
switch(id) {
case 'InputUpVerCode':
if(val != '' && val.length == 6){
$(this).parent().removeClass('error').addClass('not_error');
$('#vercode').removeClass('signup').addClass('signin').removeAttr('disabled');
}else{
$(this).parent().removeClass('not_error').addClass('error');
$('#vercode').removeClass('signin').addClass('signup').prop('disabled', true);
}
break;
}
});
$mail = $_POST['mail'];
$code = $_POST['vercode'];
$db->query("SELECT * FROM users WHERE email = '$mail'");
$user = $db->FetchArray();
$code2 = $user['vercode'];
if($code == $code2) {
echo "Успеншо!";
} else {
?>
<span class="error">Не верный код!</span>
<p>На почту <?=$mail; ?> было отправлено сообщение с кодом подтверждения:</p>
<div class="input">
<span>Ваш Код:</span>
<input type="text" id="InputUpVerCode">
</div>
<a href="">Отправить еще раз</a>
<button class="signup" id="vercode" disabled type="button">Подтвердить</button>
<span class="signin" style="text-align: center; cursor: pointer; display: block;" type="button" onclick="goSignIn();">Войти</span>
<script>
$(document).ready(function(){
$('input#InputUpVerCode').keyup(function(){
var id = $(this).attr('id');
var val = $(this).val();
switch(id) {
case 'InputUpVerCode':
if(val != '' && val.length == 6){
$(this).parent().removeClass('error').addClass('not_error');
$('#vercode').removeClass('signup').addClass('signin').removeAttr('disabled');
}else{
$(this).parent().removeClass('not_error').addClass('error');
$('#vercode').removeClass('signin').addClass('signup').prop('disabled', true);
}
break;
}
});
$('#vercode').click(function(e){
var mail = "<?=$mail; ?>";
e.preventDefault();
if($('.not_error').length == 1){
$.ajax({
url: '/ajax/signup.vercode.php',
type: 'post',
data: {"vercode": $('#InputUpVerCode').val(), "mail": mail},
dataType: "html",
success: function(html){
$('.modal-body').html(html);
}
});
}else{
return false;
}
});
</script>
<?php
}
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question