Forums

Cannot get validation to work.

rankman 03 Jun, 2007
Hello,

I've done the following:

Form HTML area:

<html>
<head>
<title>JavaScript Form Validation Example</title>
<style type="text/css">
body
{
background:white;
font-size:12px;
font-family:arial;
}
table
{
background:navy;
color:white;
font-weight:bold;
}
</style>




</head>

<body>
<table border="1">

<tr>
<td>Name:</td>
<td><input type="text" name="fullName" length="25"></td>
</tr>

<tr>
<td>Email:</td>
<td><input type="text" name="email" length="25"></td>
</tr>

<tr>
<td>Phone Number</td>
<td><input type="text" name="phoneNum" length="25"></td>
</tr>

<tr>
<td><input type="submit" name="submit" value="Submit"></td>
<td><input type="reset" name="reset"></td>
</tr>

</table>


</body>
</html>

Form Javascript Area:

function validateForm(contact)
{

if(document.forms.contact.fullName.value=="")
{
alert("Please enter your full name.");
document.forms.contact.fullName.focus();
return false;
}

if(document.forms.contact.email.value=="")
{
alert("Please enter your email address.");
document.forms.contact.email.focus();
return false;
}

if(document.forms.contact.phoneNum.value=="")
{
alert("Please enter your phone number.");
document.forms.contact.phoneNum.focus();
return false;
}

}


Form tag attachment:

onSubmit="return validateForm(contact);"


It wont do the validation thing but goes directly to the submitted page.

Can anyone tell me what i'm doing wrong :blush: ?
rankman 03 Jun, 2007
I found the solution.

The probkem was the formname because is adds "ChronoContact_"

Rankman
vrwired 07 Jun, 2007
see message below... gotta dup on this to subscribe to thread<br><br>Post edited by: vrwired, at: 2007/06/07 09:17
vrwired 07 Jun, 2007
uhh.. i'm missing somehtin here. I'm havin the same issue with the form passing on without runnig validation. i put an alert in to see my jscript is running and it is, but i must not be calling the document.form correctly (the form is called JR).

could you please help? my url is http://jrhuston.biz/biz/index.php?option=com_chronocontact&chronoformname=jr&Itemid=28

ps. i'm already approved to get the license for this, so am looking forward to getting this fully functional and then legally deleting the link.
GreyHead 07 Jun, 2007
Hi,

I get the JavaScript alert 'here' on your page so the script is entering OK.

Bob<br><br>Post edited by: GreyHead, at: 2007/06/07 10:52
Max_admin 07 Jun, 2007
Hi,

at your validations javascript code you always use this format :

if (document.JR.firstname.value == ""«») {


but you need to edit any reference to your form name (JR) to be : (ChronoContact_JR)

The issue is just as solved in the above messages in this thread with another user!!😉

Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.