PDA

View Full Version : JavaScript --required fileds /forms


hearts
12-27-1998, 05:03 PM
wanting to know what the script would be for required fields in (email) forms. I know it would this would go between the <head></head> tags.. and if the "name=" has a space between two words affects how this script is written.

Example :
<INPUT name="Your Name" size=40 Value="">

Please and thank you.

Deb
12-27-1998, 05:10 PM
Which form mail script are you using?

The requirements may vary a bit depending on the script...

Let us know

Deb

hearts
12-27-1998, 05:16 PM
mail script? I just typed the code for the form.. but I have no script. I just do not want to recieve a partially filled out form.

Here is what I found on the net.. but it didn't validate.. it said frm.name. was not defined.


Place the following piece of Javascript code in your HTML FORM file between <head> & </head>.

Also, add ( onSubmit = "return validate()" ) to your <form> tag as shown below,

<form name="frm" action="your_file/mail address" onSubmit="return validate()">

The Javascript code is as follows. However, please tailor the code as per your needs.

============================================================

<script language="JAVASCRIPT">

function validate() {

if(frm.name.value == "")
{
alert("Please enter your good Name!!!");
return false;
}

if(frm.emailaddress.value == "")
{
alert("Please enter your e-mail address!!!");
return false;
}

return true;

}

</script>


i musta done something wrong http://www.aota.net/ubb/frown.gif

hearts
12-27-1998, 05:23 PM
duh.. i think I figured out my mistake.. maybe i just needed to see this code on a blue background.. http://www.aota.net/ubb/wink.gif

I will give it a try http://www.aota.net/ubb/smile.gif

Deb
12-27-1998, 05:25 PM
Do you NEED to use JavaScript for this?

Have you considered just using the mailform we offer stock with your account? It would probably be a lot easier to setup and making sure fields are required is mega easy....

http://www.aota.net/CNC/ holds a lil auto script that will generate the basics for you and http://www.aota.net/Tutorials/ holds the docs for adding and expanding it's capabilities...

If you need the script you're trying to use now though I'll take a closer look and see if I can help..

Deb

hearts
12-27-1998, 05:31 PM
nope.. it didn't
awwwwwwwww.. heck. http://www.aota.net/ubb/frown.gif

hearts
12-27-1998, 05:33 PM
well.. i wanted to learn something.. not take the easy way out.. *if that makes sense*

should I just email you this?

Deb
12-27-1998, 05:38 PM
heh no.. email would get you less help rather then more help on this one...

We promise to support the server 'stuff' but can't promise to know all the languages people use to build their sites http://www.aota.net/ubb/smile.gif I'm not a javascript pro... So you're more apt to get the right help, here in the forums.

Do you have the script up on your site somewhere? (the url where I can see it broken at?)

Deb

hearts
12-27-1998, 06:46 PM
hehehe.. thanks Deb.. but I found a script that was easier .. *cut and paste* .. *I love the right click of a mouse* http://www.aota.net/ubb/wink.gif

so much for learning something new!