/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Registration page stalls after using modal

The registration page worked fine until I added a modal. The modal lays out a non-disclosure agreement. When the user click the Continue button on the modal, the flow is sent back to the main page. But the ajax no longer processes. The page just sits there.

Firstly, I harvest the input variables from the registration form. If everything there is okay, then it allows the user to click the Registration button, which then shows a modal with an NDA on it. Once they check the “I agree checkbox”, then the Continue button becomes enabled for them to click.

[code=html]
$(‘#register’).click(function(){

var setservice = $(‘#service’).val();
if(setservice == “22”){
$(‘#serviceErr’).html(“Please Select a Service”).show().delay(3000).fadeOut(“slow”);
$(‘#service’).focus();
return false;
}

var setfname = $(‘#fname’).val();
if(setfname == “”){
$(“#fnameErr”).html(“Field cannot be Empty”).show().delay(3000).fadeOut(“slow”);
$(‘#fname’).focus();
return false;
}

var setlname = $(‘#lname’).val();
if(setlname == “”){
$(“#lnameErr”).html(“Field cannot be Empty”).show().delay(3000).fadeOut(“slow”);
$(‘#lname’).focus();
return false;
} …

$(‘#myModal’).modal(‘show’);
$(‘#agree’).click(function(){
/* CHECK THE AGREEMENT BOX */
if ($(‘#agree’).is(‘:checked’)) {
$(‘#continue’).prop(‘disabled’, false);
} else {
$(‘#continue’).prop(‘disabled’, true);
}
});

});

$(‘#continue’).click(function(){
$(‘#myModal’).modal(‘hide’);
$.ajax({
url : ‘register.php’,
type : ‘POST’,
async : true,
data : {
‘register’ : 1,
‘fname’ : setfname,
‘lname’ : setlname,
‘phone’ : setphone,
’email’ : setemail,
‘pwd1’ : setpwd1,
‘timezone’ : settimezone,
‘captcha’ : setcaptcha,
‘service’ : setservice
},
success:function(re){
if(re == “error”){
errorpage();
}
if(re == “0”){
window.location.replace(“https://www.website.com/confirmemail.html”);
}
if(re == “2”){
$(‘#captchaErr’).html(“CAPTCHA Incorrect”).show().delay(3000).fadeOut(“slow”);
$(‘#captcha’).focus();
return false;
}
}

});
});[/code]

I’m new to using modals, so I’m sure I’ve done something silly here. Any help would be appreciated. Thanks.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@LandslydeauthorSep 01.2016 — Like I said: something silly.

The fix: move the[B][I] continue[/I][/B] button click event inside the[B][I] register[/I][/B] button click event. That's why it was stalling; it'd lost scope of the variables and had nothing to process.

Fell asleep at the wheel ?
Copy linkTweet thisAlerts:
@rootSep 03.2016 — You should ask framework questions in the frameworks forum ?
×

Success!

Help @Landslyde spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...