sheetrum said:
Here are some of the instructions that came with the script:
The first step in using this script is to select the code from the text
box
below and copy it into a file called email.js.
You next attach the script into your web page that has forms containing
email addresses by adding the following code into the head section of your
page.
<script type="text/javascript" src="email.js">
</script>
All that remains then is to call it using the following statement from
either the onblur event of the email field itself and / or the onclick or
onsubmit event of the submission button or form:
valid_email =
validateEmail(email_field,mandatory,messages);
I am new to scripting, so all code that I have previously done was by copy
and paste. After a little trial and error, I was able to make it do what
I
needed. What is the difference between an external js file and inserting
the
script into the code?
In your post you stated that the input type for the button would look like
this:
eg <input type="submit" name="submit" value="Submit" >
onsubmit="validateEmail();">
Can you better explain the ="validateEmail();" part of that code
and
what it is referring to?
The above code I provided is an example of what the instructions said -
using the "onsubmit" event - and it was just a 'guess' - I don't know if the
syntax is correct or not. The script's instructions should provide precise
details I'd expect.
The difference between external js file and putting the code in the html
page : if you have a script that is 200 lines of code, you might need to use
such a script a few times; that means copying that code into several pages,
and if there are errors in the code, you have to go through every copy of
the script to fix the errors.
With the external js file, you insert one line of code: > <script
type="text/javascript" src="email.js">
</script> and you're done. For debugging or troubleshooting the script,
you open the js file in either notepad or in Frontpage and you can fix the
code errors in one file, which when saved and published will then work
correctly across all the pages using it.