When I run this code, I click submit on the form and nothing happens. The adding event handler part of the code, I got from a Lynda_com tutorial so I’m pretty sure it’s accurate, I’m just screwing up something basic I think. I’d appreciate any help.
Lynda.com Practical and Effective JavaScript video series.
I’m simply exploring with JavaScript. With the above code, it’s only supposed to send an alert message. I’m getting no alert message. Even with the following code, no alert message:
Well, that course has Exercise Files that are copies of the identical files that Lynda uses in her tutorial.
As Lynda’s training material is behind a pay-wall, which I suspect that you have access to as you are taking her tutorial, I suggest that you obtain those exercise files yourself, try them out to confirm that they work, and then compare the working one with your non-working one.
Alright I’ll check again. I have the Excercise Files.
I’m just surprised that my code in the second case didn’t work. I’m assuming it’s fairly basic… the event handler actually in the HTML connecting to one function which simply says alert(“test”);.
Edit: Even weirder, the Exercise Files work in IE and FireFox, but not in Google Chrome (and it’s running JavaScript). Does Google Chrome handle JavaScript differently?
There are a couple of differences that can be made to make it work. I’ll go over the parts that you need to pay closer attention to, so that you can go back over the tutorial and rediscover what should be there.
First, is to assign a function to the submit event. Currently the regExpression function is being run directly. That needs to be contained within an anonymous function instead.
Second, is during the load event where you pass an object to alertInput. You don’t want to pass it the submit button itself to alertInput, because the submit button doesn’t have a submit event. Instead, you want to pass a reference to the form itself.
Go back over those and see what more you can learn about them from the tutorial.
He has the sample files from which he can obtain the original working code.
He has the tutorial videos that teach him how to create the working code.
He has the explanations of what needs to be done to create working code.
I am not going to explicitly write the working code.
In this situation he will learn more from the act of studying the sample code and the video tutorial more closely, in concert with the provided advice, so that he can find and learn about the issues at hand.