html_code_clinic thread: Using javascript to check a form and then submit info.
Well If they have JS turned off document.<form name>.submit() will never
get excecuted
And what will happen to your code if I enter a space for my name
if (form.contactname.value=="")//will not work with " " as values
What you have to do is strip all leading and trailing spaces from the
field and then check for if (form.contactname.value=="")
Good Luck
-----Original Message-----
From: Greg Griffiths [mailto:griffiths@x...]
Sent: Tuesday, September 25, 2001 3:53 PM
To: HTML Code Clinic
Subject: [html_code_clinic] Re: Using javascript to check a form and
then submit info.
to submit it try ;
document.<form name>.submit()
As mentioned by a previous poster, you should also validate on the
server
side as some people will browse with JS off.
At 14:46 25/09/01 +0000, you wrote:
>Hi,
>
>Thanks for the feedback earlier - things have progressed a little since
>then!
>
>As the title of this message suggests I'm trying to use javascript to
>check for mandatory fields on a form and then post that information to
>an e-mail account if it is there.
>
>Below is the javascript that I am using. I have the form set up with a
>button which "onClick" runs this particular script. What I would like,
>is to insert another line of coding, after the "Thankyou alert box" to
>actually send this information to an e-mail account.
>
>I'm sure that this is quite simple, but having never done it, I would
>appreciate any advice you guys and gals can give me.
>
>Cheers,
>Michaela
>
><script language="javascript">
><!-- Hide
>
>function test1(form) {
> if (form.contactname.value=="")
> alert("Please enter your name!")
>
> else if (form.emailaddress.value=="")
> alert("please enter your e-mail address!")
>
> else {
> alert("Thank you, your details will be processed as
>soon as possible");
> }
>}
>//-->
></script>
>