Gossamer Forum
Home : General : Perl Programming :

validateForm()

Quote Reply
validateForm()
Sorry for the wrong Forum, but I hope someone answers my question.

Normaly I use validateForm() for all my fieds, but fot this javascript the name of the field must be 1 word (eq fullname)

Just like: <input type=text size="30" name="fullname">

But what if I would like to name the fiels "Full Name", like <input type=text size="30" name="Full Name">

document.search.Full Name.value WILL NOT work!


Code:
<script type="text/javascript" language="JavaScript"><!--

function validateForm() {

if (document.search.fullname.value=="")
{alert('Please fill in your real name!');
return false}
else return true;}

//--></script>

[This message has been edited by ds (edited February 28, 1999).]
Quote Reply
Re: validateForm() In reply to
Can't I'm afraid. There are restrictions on what you can call javascript variables. For instance you can't use a leading number (i.e. have a field called '12Name' wouldn't work).

You could try accessing the form element through an array. Something like
document.form1.elements[5].value

but you'd have to look up the syntax somewhere as I'm pretty sure that's not correct.

Cheers,

Alex