Hi Exceter,
Could you put the document.getElementById('t
onclick="validateForm()"
function validateForm() {
if () {do this}
ETC ETC
else {document.getElementById('
}
Cheers
Main Topics
Browse All TopicsI've been attempting to validate my forms with the code I found here,
http://www.javascript-code
This works perfectly if I use a standard html <input type="submit"... However, if javascript is disabled in the client's browser, this would allow the form to be submitted without being validated. I want to submit the form with a button that does nothing without javascript. That way, if the client had javascript disabled, they can't submit the form. I've succeeded in getting the form to submit using,
<button type = "button" name = "bsubmit" onClick="document.getEleme
where test is the name of the form. This submits the form but the validation routines are not called. How can I use javascript to call the validator before the form is submitted?
Cheers!
Exceter
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Mark, I tried your suggestions and the JavaScript console in Firefox spit this back at me,
Error: frmvalidator.form_submit_h
Source File: http://www.msivt.com/zeus2
Line: 1
Steggs, that was my original thought too. However, my javascript experience is limited and I'm not entirely sure how to invoke the validator programatically.
Some of this will be very ugly. I'm working on a form generator using PHP and I wanted it to automatically spit out validation code as well as the form. The resulting HTML is typically a mess.
<html>
<head>
<title>Testing</title>
<script language="javascript" src="../lib/confirm_pop.js
<link type="text/css" rel="stylesheet" href="../lib/css.css">
<script language="JavaScript" src="../lib/javascript/val
</head>
<body style = "background-image: url('http://www.msivt.com/
<table width="100%" height="100%" border="0">
<tr>
<td align="center" valign="top">
<table class="main-table" style="position:relative;"
<tr>
<td bgcolor="#ffffff">
<table cellspacing="0" cellpadding="0" width="100%">
<tr>
<td width="50%">
<div align="left" class="h5">Manufacturing Solutions, Inc.</div>
</td>
<td width="50%" align="right">
<a href="../admin.php">[Admin
<a href="../main.php">[ Dashboard ]</a>
<a href="../log_out.php?log_o
</td>
</tr>
<tr>
<td style = "font-style: italic; text-align: left;">
Tuesday February 20, 2007 9:18:45 AM </td>
</tr>
<tr>
<td colspan="2">
<div align="center" class="h1">Testing</div>
<div align="center">
<a href="century/main.php">[ Century ]</a>
<a href="quality/module/index
<a href="inventory/index.php"
<a href="communication/index.
<a href="hr/index.php">[ Human Resources ]</a>
<a href="preferences.php">[ Preferences ]</a></div>
</td>
</tr>
<tr>
<td colspan="2">
<div align="center" class=""></div><br>
</td>
</tr>
<tr>
<td align="center" colspan="2" style="vertical-align:top;
</tr>
</table>
<br>
<table class="main-table">
<tr>
<td bgcolor="#ffffff">
<table cellspacing="0" cellpadding="0" width="100%">
<tr>
<td>
<div align="left" class="fineprint">
Page Execution Time: 0.017 Seconds<br>
Query Timestamp: 2007/02/20 09:18:45<br>
User: DunlapJ<br>
</div>
</td>
<td>
<div align="right" class="fineprint">
Permission: general<br>
Page Version: [ v2.5.07.02.20.08 ]<br>
IP Address: 10.150.199.117<br>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
try changing
function form_submit_handler()
{
for(var itr=0;itr < this.elements.length;itr++
{
if(this.elements[itr].vali
!this.elements[itr].valida
{
return false;
}
}
if(this.addnlvalidation)
{
str =" var ret = "+this.addnlvalidation+"()
eval(str);
if(!ret) return ret;
}
return true;
}
to
function form_submit_handler(theFor
{
for(var itr=0;itr < theForm.elements.length;it
{
if(theForm.elements[itr].v
!theForm.elements[itr].val
{
return false;
}
}
if(theForm.addnlvalidation
{
str =" var ret = "+theForm.addnlvalidation+
eval(str);
if(!ret) return ret;
}
return true;
}
and use
<input type="button" onClick="if (form_submit_handler(this.
Michel
Business Accounts
Answer for Membership
by: mark-bPosted on 2007-02-20 at 05:50:59ID: 18570287
Assuming your validator is called 'frmvalidator', then try this:
handler() ) document.getElementById('t est').subm it();">Sub mit</butto n>
<button type = "button" name = "bsubmit" onClick="if (frmvalidator.form_submit_
-Mark