<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
if(loc == -1)
alert('you entered an inaccurate email addy.')
<FORM action="http://www.jimkeogh.com" method="post">
First Name: <INPUT type="text" name="Fname"/><BR>
Last Name: <INPUT type="text" name="Lname"/><BR>
Email: <INPUT type="text" name="Email" onblur="ValidateEmail (this.value)"/><BR>
<INPUT name="Submit" value="Submit" type="submit"/>
<INPUT name="Reset" value="Reset" type="reset"/>
When I try to load it in a browser, the form loads fine but the browser isn't displaying an alert box. So I don't even know if it is calling the function correctly. Could someone look over this and explain whats going on or what I've done wrong?
All that is needed is some basic Debugging 101
The Firefox error console tells you what the error is and the line number its in.
You have an obvious syntax error.
It is saying the error is in line 1, and is pointing out ValidateEmail portion of the function, saying it is not defined. see below pic. I'm not sure why it's not defined and could you please point out what I need to do here?
well I don't know how I got it working, all I did was removed the junk in the html tag and the doctype line. So... I'm lost on that part but it is working fine now.
Please use the html and the code tags, also put better topic titles, that really describe what's you're question.
Keep the forums clean and organized.
"Scripting is the future of the development languages"
--Nathan Paulino Campos(me)
The script you provided works fine.
You seem to be confused on what an onblur event is.
A user clicks on the form field, and it focuses on that field. This is called onfocus.
The user then clicks out of the form field, and it is not longer focused. This is called onblur.
So, enter an email address into the form field, and then click out of the field. Your alert box should appear.
To ziggyism, I'm glad the code I provided is working correctly for you... it's nice to know that it is working properly. I'm quite clear on what the onblur and all the other tags that you can use like it do, what I was really concerned about was the fact that the browser would not execute that code correctly, tho it was copied verbatim from the book. I'm having similar issues with a couple of other examples on into chap 7 of the book.
And to nathanpc, the topic title was to get people to look at the forum post quickly , know that im new, and once you read the question contained in my first forum post then you know exactly what I was asking (tho sorry if it wasn't up to par for you). And i never said i got rid of the html and code tags i said i got rid of the junk in them... aka the parts that were completely unnecessary.
By removing the extra text in the <html> you removed the source of the error - missing closing "
Originally Posted by techdead
In your original post:
should have been
Aha! Thank you Tirna! I knew it would be something like that... I had been so annoyed over that.
no problem - glad you sorted it out.
Imo code in text or any books should not be blindly taken as 100% correct. There is always a possibility if typos or misprints - albeit these are rare.
.....tho it was copied verbatim from the book. I'm having similar issues with a couple of other examples on into chap 7 of the book.....
Depending on the problem, sources of errors in problematic html code can be found by putting the hml code through the w3c validator at:
anyway, just some food for thought
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)