/    Sign up×
Community /Pin to ProfileBookmark

Form validation HELP! On submit autosum

Hi i’ve got an issue with validating a sum field…

So i have a result field… the sums up 10 fields. In order to submit the data, the calculated field must equal 0. How do i get a prompt for that?

-Hyrum

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@PadonakApr 09.2007 — by onmouseover alert. there are many ways to tell the user something but this one is the simpliest
Copy linkTweet thisAlerts:
@hdoggauthorApr 09.2007 — Let me be more specific.

So the code works fine as far as loading the fields AFTER i click the field and change it.... however.. as you can see I have default values in the field that need to have the sumfunction sum them when users type stuff(which it does) but also sum them when it loads...

Then when they click submit if the sum isn't a certain value, then display an alert..

Thanks,

Hyrum


<form name=batch action =http://forecast.php?action=post&jobcode=01332&name=update method=post>

<td>30-NOV-04<input type=hidden value=30-NOV-04 name=forecastedmonth[] ></td>

<td> <input type=text name=forecast[] value=0 onChange=calc() onFocus=startCalc() onBlur=stopCalc() > </td>

<td>04/09/07 : 13:33:00</td><td>9387<input type=hidden value=9387 name=id[] > <td></tr>

<tr>

<td>24</td>
<td> 31-JAN-03<input type=hidden name=month[] value= 31-JAN-03></td>
<td>31-DEC-04<input type=hidden value=31-DEC-04 name=forecastedmonth[] ></td>
<td> <input type=text name=forecast[] value=0 onChange=calc() onFocus=startCalc() onBlur=stopCalc() > </td>
<td>04/09/07 : 13:33:00</td><td>9388<input type=hidden value=9388 name=id[] > <td></tr> Records: 24<BR>


<tr><td></td><td></td><td></td><td>To be Forecast in Later Periods<BR>

<input type=text name=futureforecast onChange=calc() onFocus=startCalc() onBlur=stopCalc()><BR>

<tr><td></td><td></td><td></td><td>

<tr>

<td></td><td></td><td></td>

<td>

Amount Forecasted:<BR>

<input type=text name=box4 onChange=calc() onFocus=startCalc() onBlur=stopCalc()>

</td>

</tr>

<tr><td></td><td></td><td></td><td>

Left to Forecast:<BR>

<input type=text name=remainder onChange=calc() onFocus=startCalc() onBlur=stopCalc()><BR>



</td></tr>

<tr><td></td><td></td><td></td><td><input type=submit value=PostBatch></form></td></tr>

</table>
Copy linkTweet thisAlerts:
@PadonakApr 09.2007 — there were markup errors and ive fixed them. try this:

&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&gt;

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Autosum&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;form name="batch" action="http://forecast.php?action=post&amp;jobcode=01332&amp;name=update" method="post"&gt;
&lt;table align="center" width="70%" border="1" cellpadding="5" cellspacing="10"&gt;
&lt;tr&gt;
&lt;td&gt;30-NOV-04&lt;input type="hidden" value="30-NOV-04" name="forecastedmonth[]"&gt;&lt;/td&gt;
&lt;td&gt; &lt;input type="text" name="forecast[]" value="0" onChange="calc()" onFocus="startCalc()" onBlur="stopCalc()"&gt; &lt;/td&gt;
&lt;td&gt;04/09/07 : 13:33:00&lt;/td&gt;
&lt;td&gt;9387&lt;input type="hidden" value="9387" name="id[]"&gt;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td&gt;24&lt;/td&gt;
&lt;td&gt; 31-JAN-03&lt;input type="hidden" name="month[]" value="31-JAN-03"&gt;&lt;/td&gt;
&lt;td&gt;31-DEC-04&lt;input type="hidden" value="31-DEC-04" name="forecastedmonth[]"&gt;&lt;/td&gt;
&lt;td&gt;
Records: 24&lt;br /&gt;
&lt;input type="text" name="forecast[]" value="0" onChange="calc()" onFocus="startCalc()" onBlur="stopCalc()"&gt;
&lt;br /&gt;
&lt;/td&gt;
&lt;td&gt;04/09/07 : 13:33:00&lt;/td&gt;
&lt;td&gt;9388&lt;input type="hidden" value="9388" name="id[]"&gt; &lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;
To be Forecast in Later Periods
&lt;br /&gt;
&lt;input type="text" name="futureforecast" onChange="calc()" onFocus="startCalc()" onBlur="stopCalc()"&gt;
&lt;br /&gt;
&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;
Amount Forecasted:
&lt;br /&gt;
&lt;input type="text" name="box4" onChange="calc()" onFocus="startCalc()" onBlur="stopCalc()"&gt;
&lt;br /&gt;
&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;
Left to Forecast:&lt;br /&gt;
&lt;input type="text" name="remainder" onChange="calc()" onFocus="startCalc()" onBlur="stopCalc()"&gt;
&lt;br /&gt;
&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;
&lt;input type="submit" value="PostBatch"&gt;
&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;

&lt;script language="JavaScript" type="text/javascript"&gt;
&lt;!--
window.onload = function(){setTimeout('document.forms["batch"].reset()',250);}
//--&gt;
&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@hdoggauthorApr 09.2007 — hey thanks so much!!!

cheers-

Hyrum
Copy linkTweet thisAlerts:
@PadonakApr 10.2007 — ?
×

Success!

Help @hdogg spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...