How can I enable the input if the two ajax functions check that there is no email and the user











up vote
0
down vote

favorite












I have a form checking real-time username and email.



     $('#email').blur(function() {
$th = $(this);
$.ajax({
url: 'check.php',
type: 'POST',
data: {email: $th.val()},
success: function(data){
$("#resultEmail").html("* "+data);
},
error: function(){
$("#error").html("Error");
}
});//ajax 1
})

$('#username').blur(function() {
$th = $(this);
$.ajax({
url: 'check.php',
type: 'POST',
data: {username: $th.val()},
success: function(data){
$("#resultUser").html("* "+data);
},
error: function(){
$("#error").html("Error");
}
});//ajax 2
});


HTML



<div class="input">
<input type="text" name="username" id="username" required="required" pattern="^[a-zA-Z0-9]+$" class="input-field"/>
<label for="username" class="label-field">Username <div id="resultUser">*</div></label>
</div>

<div class="input">
<input type="email" name="email" id="email" class="input-field" required="required"/>
<label for="email" class="label-field">E-mail <div id="resultEmail">*</div></label>
</div>
<input type="submit" name="enviar" id="enviar" value="Enviar" disabled />


How can I make the input be enabled if the requests verify that the username and the email do not exist in the database



in check.php page if there is email or username print



    $rows = $query->num_rows;

if($rows>0){
echo "exists in DB";
}









share|improve this question
























  • If you're already using jQuery, you should look at using Deferred objects to achieve this. Specifically, if you want to have two separate AJAX requests that you only act upon when both are complete/successful, the .when() method allows this: api.jquery.com/jquery.when
    – Stevangelista
    Nov 11 at 23:15










  • I would suggest you do all the checking during submit of the form. That way is more user friendly in my opinion.
    – guradio
    Nov 11 at 23:52















up vote
0
down vote

favorite












I have a form checking real-time username and email.



     $('#email').blur(function() {
$th = $(this);
$.ajax({
url: 'check.php',
type: 'POST',
data: {email: $th.val()},
success: function(data){
$("#resultEmail").html("* "+data);
},
error: function(){
$("#error").html("Error");
}
});//ajax 1
})

$('#username').blur(function() {
$th = $(this);
$.ajax({
url: 'check.php',
type: 'POST',
data: {username: $th.val()},
success: function(data){
$("#resultUser").html("* "+data);
},
error: function(){
$("#error").html("Error");
}
});//ajax 2
});


HTML



<div class="input">
<input type="text" name="username" id="username" required="required" pattern="^[a-zA-Z0-9]+$" class="input-field"/>
<label for="username" class="label-field">Username <div id="resultUser">*</div></label>
</div>

<div class="input">
<input type="email" name="email" id="email" class="input-field" required="required"/>
<label for="email" class="label-field">E-mail <div id="resultEmail">*</div></label>
</div>
<input type="submit" name="enviar" id="enviar" value="Enviar" disabled />


How can I make the input be enabled if the requests verify that the username and the email do not exist in the database



in check.php page if there is email or username print



    $rows = $query->num_rows;

if($rows>0){
echo "exists in DB";
}









share|improve this question
























  • If you're already using jQuery, you should look at using Deferred objects to achieve this. Specifically, if you want to have two separate AJAX requests that you only act upon when both are complete/successful, the .when() method allows this: api.jquery.com/jquery.when
    – Stevangelista
    Nov 11 at 23:15










  • I would suggest you do all the checking during submit of the form. That way is more user friendly in my opinion.
    – guradio
    Nov 11 at 23:52













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have a form checking real-time username and email.



     $('#email').blur(function() {
$th = $(this);
$.ajax({
url: 'check.php',
type: 'POST',
data: {email: $th.val()},
success: function(data){
$("#resultEmail").html("* "+data);
},
error: function(){
$("#error").html("Error");
}
});//ajax 1
})

$('#username').blur(function() {
$th = $(this);
$.ajax({
url: 'check.php',
type: 'POST',
data: {username: $th.val()},
success: function(data){
$("#resultUser").html("* "+data);
},
error: function(){
$("#error").html("Error");
}
});//ajax 2
});


HTML



<div class="input">
<input type="text" name="username" id="username" required="required" pattern="^[a-zA-Z0-9]+$" class="input-field"/>
<label for="username" class="label-field">Username <div id="resultUser">*</div></label>
</div>

<div class="input">
<input type="email" name="email" id="email" class="input-field" required="required"/>
<label for="email" class="label-field">E-mail <div id="resultEmail">*</div></label>
</div>
<input type="submit" name="enviar" id="enviar" value="Enviar" disabled />


How can I make the input be enabled if the requests verify that the username and the email do not exist in the database



in check.php page if there is email or username print



    $rows = $query->num_rows;

if($rows>0){
echo "exists in DB";
}









share|improve this question















I have a form checking real-time username and email.



     $('#email').blur(function() {
$th = $(this);
$.ajax({
url: 'check.php',
type: 'POST',
data: {email: $th.val()},
success: function(data){
$("#resultEmail").html("* "+data);
},
error: function(){
$("#error").html("Error");
}
});//ajax 1
})

$('#username').blur(function() {
$th = $(this);
$.ajax({
url: 'check.php',
type: 'POST',
data: {username: $th.val()},
success: function(data){
$("#resultUser").html("* "+data);
},
error: function(){
$("#error").html("Error");
}
});//ajax 2
});


HTML



<div class="input">
<input type="text" name="username" id="username" required="required" pattern="^[a-zA-Z0-9]+$" class="input-field"/>
<label for="username" class="label-field">Username <div id="resultUser">*</div></label>
</div>

<div class="input">
<input type="email" name="email" id="email" class="input-field" required="required"/>
<label for="email" class="label-field">E-mail <div id="resultEmail">*</div></label>
</div>
<input type="submit" name="enviar" id="enviar" value="Enviar" disabled />


How can I make the input be enabled if the requests verify that the username and the email do not exist in the database



in check.php page if there is email or username print



    $rows = $query->num_rows;

if($rows>0){
echo "exists in DB";
}






php jquery database






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 at 21:52









marc_s

569k12811001250




569k12811001250










asked Nov 11 at 23:07









Leo Caracciolo

11416




11416












  • If you're already using jQuery, you should look at using Deferred objects to achieve this. Specifically, if you want to have two separate AJAX requests that you only act upon when both are complete/successful, the .when() method allows this: api.jquery.com/jquery.when
    – Stevangelista
    Nov 11 at 23:15










  • I would suggest you do all the checking during submit of the form. That way is more user friendly in my opinion.
    – guradio
    Nov 11 at 23:52


















  • If you're already using jQuery, you should look at using Deferred objects to achieve this. Specifically, if you want to have two separate AJAX requests that you only act upon when both are complete/successful, the .when() method allows this: api.jquery.com/jquery.when
    – Stevangelista
    Nov 11 at 23:15










  • I would suggest you do all the checking during submit of the form. That way is more user friendly in my opinion.
    – guradio
    Nov 11 at 23:52
















If you're already using jQuery, you should look at using Deferred objects to achieve this. Specifically, if you want to have two separate AJAX requests that you only act upon when both are complete/successful, the .when() method allows this: api.jquery.com/jquery.when
– Stevangelista
Nov 11 at 23:15




If you're already using jQuery, you should look at using Deferred objects to achieve this. Specifically, if you want to have two separate AJAX requests that you only act upon when both are complete/successful, the .when() method allows this: api.jquery.com/jquery.when
– Stevangelista
Nov 11 at 23:15












I would suggest you do all the checking during submit of the form. That way is more user friendly in my opinion.
– guradio
Nov 11 at 23:52




I would suggest you do all the checking during submit of the form. That way is more user friendly in my opinion.
– guradio
Nov 11 at 23:52

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53254150%2fhow-can-i-enable-the-input-if-the-two-ajax-functions-check-that-there-is-no-emai%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53254150%2fhow-can-i-enable-the-input-if-the-two-ajax-functions-check-that-there-is-no-emai%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Lugert, Oklahoma