1 00:00:00,180 --> 00:00:06,390 One last piece of functionality I would like to add to my logon page is the fact that when the users 2 00:00:06,840 --> 00:00:13,740 are already in the process of signing in or registering they cannot keep on clicking the submit button. 3 00:00:13,740 --> 00:00:15,270 Now let me show you what I mean by that. 4 00:00:15,590 --> 00:00:18,470 I'm going over to a bigger browser window. 5 00:00:18,480 --> 00:00:20,330 Then we're going to click on inspect. 6 00:00:20,340 --> 00:00:24,150 We're going to go to network and we're just going to make our connection slower. 7 00:00:24,150 --> 00:00:26,700 So we're gonna say let's say fast 3G. 8 00:00:26,880 --> 00:00:29,150 Now what's going to happen if we're going to head over to a console. 9 00:00:29,160 --> 00:00:35,550 And if I'm going to just clear it you can notice that if I'm let's say logging in I can keep on clicking. 10 00:00:35,580 --> 00:00:37,560 And that's not the functionality that I'm looking for. 11 00:00:37,920 --> 00:00:45,840 So what I would like to have is while my alert is displayed so essentially while we are loading or while 12 00:00:45,840 --> 00:00:51,510 we're waiting for our response from the server then the user is not going to be able to submit the form 13 00:00:51,510 --> 00:00:52,010 again. 14 00:00:52,060 --> 00:00:56,760 And you know maybe let me show you with a slow one maybe that's gonna be better. 15 00:00:56,830 --> 00:01:01,530 Again we're going to head over to our console and let me close the alert. 16 00:01:01,530 --> 00:01:06,660 I'm submitting I'm still waiting technically for the data and I can just keep on you know adding to 17 00:01:06,660 --> 00:01:08,790 many requests as you can see right now. 18 00:01:08,820 --> 00:01:15,070 So the way we're going to handle that is we're going to head over first of all to our handle submit. 19 00:01:15,090 --> 00:01:22,020 And the moment we submitted the form the moment we run and submit first we're gonna run alert. 20 00:01:22,200 --> 00:01:26,570 So when I say show alert and then we're gonna pass in the message within our object. 21 00:01:26,630 --> 00:01:35,160 So off message and then we're gonna say accessing user data and then we're gonna say Please wait. 22 00:01:35,450 --> 00:01:35,880 OK. 23 00:01:35,910 --> 00:01:43,020 That's a good start but then also remember when we talked about is empty I'm gonna tie is empty value 24 00:01:43,350 --> 00:01:44,480 to alert show. 25 00:01:44,910 --> 00:01:51,540 So what I'm saying here is if one of these values is of course empty then we cannot submit the form. 26 00:01:51,720 --> 00:01:52,320 Correct. 27 00:01:52,320 --> 00:01:53,510 That was our logic. 28 00:01:53,610 --> 00:01:55,520 So why don't we add one more value here. 29 00:01:55,940 --> 00:01:59,370 And I'm going to say also or alert. 30 00:01:59,550 --> 00:02:02,630 So my alert if this show is true. 31 00:02:02,700 --> 00:02:05,640 So if the show is true is empty is gonna be true. 32 00:02:06,150 --> 00:02:09,630 So if these empty is true then we're not displaying the bottom. 33 00:02:09,690 --> 00:02:12,480 So how it's going to work then we're gonna save it. 34 00:02:12,660 --> 00:02:18,390 We're gonna head over back to our application and pick a browser window and then of course this is just 35 00:02:18,390 --> 00:02:21,610 going to take some while since I have the slow connection. 36 00:02:21,720 --> 00:02:23,350 And now let's try to do that again. 37 00:02:23,630 --> 00:02:31,170 So I'm gonna go John G mail dot com and regardless whether the password is correct or incorrect if I'm 38 00:02:31,170 --> 00:02:35,300 going to submit something notice I'm not going to be able to submit anymore. 39 00:02:35,400 --> 00:02:37,380 So now I'm waiting for my response. 40 00:02:37,410 --> 00:02:38,930 But in this case it was successful. 41 00:02:39,150 --> 00:02:43,800 However let's head over back and try to log in with the wrong credentials and you're going to see again 42 00:02:43,800 --> 00:02:44,420 the same thing. 43 00:02:44,430 --> 00:02:51,630 John and Jim I'll let com whatever long credentials and then I cannot submit the form anymore. 44 00:02:51,630 --> 00:02:54,180 So now I'm waiting for my response. 45 00:02:54,180 --> 00:02:59,060 And then unless I have closed out my alert then of course I cannot submit. 46 00:02:59,060 --> 00:03:02,370 So again I have to specifically close out the alert. 47 00:03:02,400 --> 00:03:06,030 And only then I can resubmit my values.