Html/ JavaScript form validation

From Validation html code needed

Page 1 of 1

1 Replies - 1818 Views - Last Post: 12 January 2007 - 09:13 PM

#1 Greatc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 12-January 07

Html/ JavaScript form validation

Posted 12 January 2007 - 01:19 PM

I need to provide validation for several entry points. If the user forgets any of the following fields (Employee ID, Date, Work Area and Shift) I need a message to pop up and say please enter the field that was left blank. Also on the ID field, they must enter all 6 digits of the ID number, or I need a message to pop up and say, please enter a valid 6 digit ID number. Down in the option area when a selection choice is made that is At Risk, I need for them to be forced to pick a reason from the comment box in the next column. If the option AT RISK is picked, the form will not go any further until they have picked a comment. Example..... If they pick an AT Risk option and decide not to pick a comment in the next field and try to submit the form, I need for an message to appear to state that they need to go back and check data or enter a comment for an AT Risk Option that was picked.


Here is the current code that I have:[u]

[code]<HTML>
<HEAD>
<TITLE>Courtland Safety Department</TITLE>
<script language="Javascript" src="../mfgdwods/script/calendar.js"></script>
</HEAD>

<BODY LANGUAGE="VBScript" BGCOLOR=silver TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<br>
<form name="form1" method="get" action="CareContactAuditFormLoad.asp">
<center><font color=blue>
<H3>Care Contact Form</H3>
</font>
</center>
<br>
<hr></hr>
<tr>
<td align="right">Employee ID:</td>
<td><input type="text" name="employeeid" id="employeeid" size=4 maxlength=6 /></td>
</td>


<tr>
<td align="right">Select Date from Pull Down Menu:</td>

<script LANGUAGE="Javascript">

<!-- This script and many more are available free online at -->
<!-- The Javascript Source!! [url=http://javascript.internet.com]http://javascript.internet.com[/url] -->

<!-- Begin
today = new Date();
thismonth = today.getMonth();
thisyear = today.getYear();
thisday = today.getDate();
montharray=new Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
maxdays=montharray[thismonth-1];
if (thismonth==2) {
if ((thisyear/4)!=parseInt(thisyear/4)) maxdays=28;
else maxdays=29;
}
thismonth = "" + thismonth
if (thismonth.length == 1) {
thismonth = "0" + thismonth;
}
document.write("<form>");
document.write("<select name=dates size=1>");
for (var theday = maxdays-1; theday <= maxdays; theday++) {
var theday = "" + theday;
if (theday.length == 1) {
theday = "0" + theday;
}
document.write("<option");
if (theday == thisday) document.write(" selected");
document.write(">");
document.write(thismonth + "-" + theday + "-" + thisyear);
}

thismonth = today.getMonth()+1;
maxdays=montharray[thismonth-1];
thisday = today.getDate();
if (thismonth==2)
{
if ((thisyear/4)!=parseInt(thisyear/4)) maxdays=28;
else maxdays=29;
}

thismonth = "" + thismonth
if (thismonth.length == 1)
{
thismonth = "0" + thismonth;
}


for (var theday = 1; theday <= maxdays; theday++)
{
var theday = "" + theday;
if (theday.length == 1) {
theday = "0" + theday;
}


document.write("<option");

if (theday == thisday)

document.write(" selected");
document.write(">");
document.write(thismonth + "-" + theday + "-" + thisyear);

}document.write("</select>");
// End -->
</SCRIPT>

<!-- Script Size: 1.20 KB -->
<br>
</tr>
<hr></hr>

Work Area
</em></strong>
<tr>
<td><select name="WorkArea" id="WorkArea">
<option value=""></option>
<option value="No.30 Machine Wet End">No.30 Machine Wet End</option>
<option value="No.30Machine Dry End">No.30 Machine Dry End</option>
<option value="No.33 Machine">No.33 Machine</option>
<option value="No.33 Coater/Supercalendar">No.33 Coater/Supercalendar</option>
<option value="No.33 Winder/Roll Wrap">No.33 Winder/Roll Wrap</option>
<option value="No.34 Machine Dry End">No.34 Machine Dry End</option>
<option value="No.34 Machine Wet End">No.34 Machine Wet End</option>
<option value="No.35 Machine Dry End">No.35 Machine Dry End</option>
<option value="No.35 Machine Wet End">No.35 Machine Wet End</option>
<option value="R&U">R&U</option>
<option value="ChemLine">ChemLine</option>
<option value="Fiber Line">Fiber Line</option>
<option value="Fiber Prep">Fiber Prep</option>
<option value="Environmental">Environmental</option>
<option value="Engineering">Engineering</option>
<option value="Quality">Quality</option>
<option value="Accounting">Accounting</option>
<option value="Materials/Purchasing">Material/Purchasing</option>
<option value="Maintenance-Paper">Maintenance-Paper</option>
<option value="Maintenance-Power">Maintenance-Power</option>
<option value="Maintenance-Pulp">Maintenance-Pulp</option>
<option value="Maintenance-Central">Maintenance-Central</option>
<option value="Maintenance-PSD">Maintenance-PSD</option>
<option value="Mill Services/Storeroom">Mill Services/Storeroom</option>
<option value="Cutsize">Cutsize</option>
<option value="Production Control">Production Control</option>
<option value="Roll Finishing">Roll Finishing</option>
<option value="Warehousing & Shipping">Warehousing & Shipping</option>
<option value="Office/Other">Office/Other</option>
</select>
</td>
</tr>


<tr>
<td>SHIFT:</td>
<td>A</td>
<td><input type="checkbox" name="ashift" id="ashift" /></td>
<td>B</td>
<td><input type="checkbox" name="bshift" id="bshift" /></td>
<td>C</td>
<td><input type="checkbox" name="cshift" id="cshift" /></td>
<td>D</td>
<td><input type="checkbox" name="dshift" id="dshift" /></td>
<td>Days</td>
<td><input type="checkbox" name="dayshift" id="dayshift" /></td>
</tr>


</tr>
<!---
</form>
</tr>
--->
</table><br>
<hr></hr>
<strong><em>
PERSONAL PROTECTION: COMMENTS (If option is AT Risk, please select appropriate comment from drop-down menu. If Other is chosen, please provide
additional information in the text field)
</em></strong>
<table>

<tr>
<td align="left">1. Body Protection</td>
<td><select name="q1answer" id="q1answer">
<option value="N/A">N/A</option>
<option value="SAFE">SAFE</option>
<option value="AT RISK">AT RISK</option>
</select>
</td>
<td><select name="Comment1" id="Comment1">
<option value=""></option>
<option value="Not Present">Not Present</option>
<option value="Not Adequate">Not Adequate</option>
<option value="Does Not Fit Proper">Does Not Fit Proper</option>
<option value="OTHER">Other</option>
<td><input type="text" name="meetingsubject" size=50 id="meetingsubject" /></td>
</tr>



<tr>
<td align="left">2. Foot Protection</td>
<td><select name="q2answer" id="q2answer">
<option value="N/A">N/A</option>
<option value="SAFE">SAFE</option>
<option value="AT RISK">AT RISK</option>
</select>
</td>
<td><select name="Comment2" id="Comment2">
<option value=""></option>
<option value="Not Present">Not Present</option>
<option value="Not Adequate">Not Adequate</option>
<option value="Does Not Fit Proper">Does Not Fit Proper</option>
<option value="OTHER">Other</option>
<td><input type="text" name="meetingsubject" size=50 id="meetingsubject" /></td>

</tr>

<tr>
<td align="left">3. Hand Protection</td>
<td><select name="q3answer" id="q3answer">
<option value="N/A">N/A</option>
<option value="SAFE">SAFE</option>
<option value="AT RISK">AT RISK</option>
</select>
</td>
<td><select name="Comment3" id="Comment3">
<option value=""></option>
<option value="Not Present">Not Present</option>
<option value="Not Adequate">Not Adequate</option>
<option value="Does Not Fit Proper">Does Not Fit Proper</option>
<option value="OTHER">Other</option>
<td><input type="text" name="meetingsubject" size=50 id="meetingsubject" /></td>

</tr>

<tr>
<td align="left">4. Hearing Protection</td>
<td><select name="q4answer" id="q4answer">
<option value="N/A">N/A</option>
<option value="SAFE">SAFE</option>
<option value="AT RISK">AT RISK</option>
</select>
</td>
<td><select name="Comment4" id="Comment4">
<option value=""></option>
<option value="Not Present">Not Present</option>
<option value="Not Adequate">Not Adequate</option>
<option value="Does Not Fit Proper">Does Not Fit Proper</option>
<option value="OTHER">Other</option>
<td><input type="text" name="meetingsubject" size=50 id="meetingsubject" /></td>

</tr>

<tr>
<td align="left">5. Head Protection</td>
<td><select name="q5answer" id="q5answer">
<option value="N/A">N/A</option>
<option value="SAFE">SAFE</option>
<option value="AT RISK">AT RISK</option>

</select>
</td>
<option value=""></option>
<td><select name="Comment5" id="Comment5">
<option value=""></option>
<option value="Not Present">Not Present</option>
<option value="Not Adequate">Not Adequate</option>
<option value="Does Not Fit Proper">Does Not Fit Proper</option>
<option value="OTHER">Other</option>
<td><input type="text" name="meetingsubject" size=50 id="meetingsubject" /></td>

</tr>

<tr>
<td align="left">6. Fall Protection</td>
<td><select name="q6answer" id="q6answer">
<option value="N/A">N/A</option>
<option value="SAFE">SAFE</option>
<option value="AT RISK">AT RISK</option>

</select>
</td>
<td><select name="Comment6" id="Comment6">
<option value=""></option>
<option value="Not Present">Not Present</option>
<option value="Not Adequate">Not Adequate</option>
<option value="Does Not Fit Proper">Does Not Fit Proper</option>
<option value="OTHER">Other</option>
<td><input type="text" name="meetingsubject" size=50 id="meetingsubject" /></td>


</tr>

<tr>
<td align="left">7. Eye/Face Protection</td>
<td><select name="q7answer" id="q7answer">
<option value="N/A">N/A</option>
<option value="SAFE">SAFE</option>
<option value="AT RISK">AT RISK</option>

</select>
</td>
<td><select name="Comment7" id="Comment7">
<option value=""></option>
<option value="Not Present">Not Present</option>
<option value="Not Adequate">Not Adequate</option>
<option value="Does Not Fit Proper">Does Not Fit Proper</option>
<option value="OTHER">Other</option>
<td><input type="text" name="meetingsubject" size=50 id="meetingsubject" /></td>


</tr>

<tr>
<td align="left">8. Respiratory Protection</td>
<td><select name="q8answer" id="q8answer">
<option value="N/A">N/A</option>
<option value="SAFE">SAFE</option>
<option value="AT RISK">AT RISK</option>
</select>
</td>
<td><select name="Comment8" id="Comment8">
<option value=""></option>
<option value="Not Present">Not Present</option>
<option value="Not Adequate">Not Adequate</option>
<option value="Does Not Fit Proper">Does Not Fit Proper</option>
<option value="OTHER">Other</option>
<td><input type="text" name="meetingsubject" size=50 id="meetingsubject" /></td>


</tr>

</tr>
</table><br>
<strong><em>
PROCEDURES:
</em></strong>
<table>

<tr>
<td align="left">9. Hot work</td>
<td><select name="q9answer" id="q9answer">
<option value="N/A">N/A</option>
<option value="SAFE">SAFE</option>
<option value="AT RISK">AT RISK</option>
</select>
</td>
<td><select name="Comment9" id="Comment9">
<option value=""></option>
<option value="Procedure Not Followed">Procedure Not Followed</option>
<option value="Procedure Not Adequate">Procedure Not Adequate</option>
<option value="Procedure Needs to be Changed">Procedure Needs to be Changed</option>
<option value="OTHER">Other</option>
<td><input type="text" name="meetingsubject" size=50 id="meetingsubject" /></td>


</tr>

<tr>
<td align="left">10. Lock Out/Tag Out</td>
<td><select name="q10answer" id="q10answer">
<option value="N/A">N/A</option>
<option value="SAFE">SAFE</option>
<option value="AT RISK">AT RISK</option>
</select>
</td>
<td><select name="Comment10" id="Comment10">
<option value=""></option>
<option value="Procedure Not Followed">Procedure Not Followed</option>
<option value="Procedure Not Adequate">Procedure Not Adequate</option>
<option value="Procedure Needs to be Changed">Procedure Needs to be Changed</option>
<option value="OTHER">Other</option>
<td><input type="text" name="meetingsubject" size=50 id="meetingsubject" /></td>



</tr>
<tr>
<td align="left">11. Confined Space</td>
<td><select name="q11answer" id="q11answer">
<option value="N/A">N/A</option>
<option value="SAFE">SAFE</option>
<option value="AT RISK">AT RISK</option>
</select>
</td>
<td><select name="Comment11" id="Comment11">
<option value=""></option>
<option value="Procedure Not Followed">Procedure Not Followed</option>
<option value="Procedure Not Adequate">Procedure Not Adequate</option>
<option value="Procedure Needs to be Changed">Procedure Needs to be Changed</option>
<option value="OTHER">Other</option>
<td><input type="text" name="meetingsubject" size=50 id="meetingsubject" /></td>

</tr>

<tr>
<td align="left">12. Line Break</td>
<td><select name="q12answer" id="q12answer">
<option value="N/A">N/A</option>
<option value="SAFE">SAFE</option>
<option value="AT RISK">AT RISK</option>
</select>
</td>
<td><select name="Comment12" id="Comment12">
<option value=""></option>
<option value="Procedure Not Followed">Procedure Not Followed</option>
<option value="Procedure Not Adequate">Procedure Not Adequate</option>
<option value="Procedure Needs to be Changed">Procedure Needs to be Changed</option>
<option value="OTHER">Other</option>
<td><input type="text" name="meetingsubject" size=50 id="meetingsubject" /></td>

</tr>

</tr>
</table><br>
<strong><em>
OBSERVABLE ACTS:
</em></strong>
<table>

<tr>
<td align="left">13. Ascending/Descending</td>
<td><select name="q13answer" id="q13answer">
<option value="N/A">N/A</option>
<option value="SAFE">SAFE</option>
<option value="AT RISK">AT RISK</option>
</select>
</td>
<td><select name="Comment13" id="Comment13">
<option value=""></option>
<option value="Inadequate Training">Inadequate Training</option>
<option value="Inadequate Tools">Inadequate Tools</option>
<option value="Distracted">Distracted</option>
<option value="OTHER">Other</option>
<td><input type="text" name="meetingsubject" size=50 id="meetingsubject" /></td>

</tr>

<tr>
<td align="left">14. Body Use/Protection</td>
<td><select name="q14answer" id="q14answer">
<option value="N/A">N/A</option>
<option value="SAFE">SAFE</option>
<option value="AT RISK">AT RISK</option>
</select>
</td>
<td><select name="Comment14" id="Comment14">
<option value=""></option>
<option value="Inadequate Training">Inadequate Training</option>
<option value="Inadequate Tools">Inadequate Tools</option>
<option value="Distracted">Distracted</option>
<option value="OTHER">Other</option>
<td><input type="text" name="meetingsubject" size=50 id="meetingsubject" /></td>


</tr>

<tr>
<td align="left">15. Lifting/Lowering</td>
<td><select name="q15answer" id="q15answer">
<option value="N/A">N/A</option>
<option value="SAFE">SAFE</option>
<option value="AT RISK">AT RISK</option>
</select>
</td>
<td><select name="Comment15" id="Comment15">
<option value=""></option>
<option value="Inadequate Training">Inadequate Training</option>
<option value="Inadequate Tools">Inadequate Tools</option>
<option value="Distracted">Distracted</option>
<option value="OTHER">Other</option>
<td><input type="text" name="meetingsubject" size=50 id="meetingsubject" /></td>

</tr>

<tr>
<td align="left">16. Line of Fire</td>
<td><select name="q16answer" id="q16answer">
<option value="N/A">N/A</option>
<option value="SAFE">SAFE</option>
<option value="AT RISK">AT RISK</option>
</select>
</td>
<td><select name="Comment16" id="Comment16">
<option value=""></option>
<option value="Inadequate Training">Inadequate Training</option>
<option value="Inadequate Tools">Inadequate Tools</option>
<option value="Distracted">Distracted</option>
<option value="OTHER">Other</option>
<td><input type="text" name="meetingsubject" size=50 id="meetingsubject" /></td>

</tr>

<tr>
<td align="left">17. Pinch Points</td>
<td><select name="q17answer" id="q17answer">
<option value="N/A">N/A</option>
<option value="SAFE">SAFE</option>
<option value="AT RISK">AT RISK</option>
</select>
</td>
<td><select name="Comment17" id="Comment17">
<option value=""></option>
<option value="Inadequate Training">Inadequate Training</option>
<option value="Inadequate Tools">Inadequate Tools</option>
<option value="Distracted">Distracted</option>
<option value="OTHER">Other</option>
<td><input type="text" name="meetingsubject" size=50 id="meetingsubject" /></td>

</tr>

<tr>
<td align="left">18. Reset and Regroup</td>
<td><select name="q18answer" id="q18answer">
<option value="N/A">N/A</option>
<option value="SAFE">SAFE</option>
<option value="AT RISK">AT RISK</option>
</select>
</td>
<td><select name="Comment18" id="Comment18">
<option value=""></option>
<option value="Inadequate Training">Inadequate Training</option>
<option value="Inadequate Tools">Inadequate Tools</option>
<option value="Distracted">Distracted</option>
<option value="OTHER">Other</option>
<td><input type="text" name="meetingsubject" size=50 id="meetingsubject" /></td>


</tr>

<tr>
<td align="left">19. Assistance</td>
<td><select name="q19answer" id="q19answer">
<option value="N/A">N/A</option>
<option value="SAFE">SAFE</option>
<option value="AT RISK">AT RISK</option>

</select>
</td>
<td><select name="Comment19" id="Comment19">
<option value=""></option>
<option value="Inadequate Training">Inadequate Training</option>
<option value="Inadequate Tools">Inadequate Tools</option>
<option value="Distracted">Distracted</option>
<option value="OTHER">Other</option>
<td><input type="text" name="meetingsubject" size=50 id="meetingsubject" /></td>

</tr>

<tr>
<td align="left">20. Tool Use/Selection</td>
<td><select name="q20answer" id="q20answer">
<option value="N/A">N/A</option>
<option value="SAFE">SAFE</option>
<option value="AT RISK">AT RISK</option>
</select>
</td>
<td><select name="Comment20" id="Comment20">
<option value=""></option>
<option value="Inadequate Training">Inadequate Training</option>
<option value="Inadequate Tools">Inadequate Tools</option>
<option value="Distracted">Distracted</option>
<option value="OTHER">Other</option>
<td><input type="text" name="meetingsubject" size=50 id="meetingsubject" /></td>

</tr>

<tr>
<td align="left">21. Use of Equipment</td>
<td><select name="q21answer" id="q21answer">
<option value="N/A">N/A</option>
<option value="SAFE">SAFE</option>
<option value="AT RISK">AT RISK</option>

</select>
</td>
<td><select name="Comment21" id="Comment21">
<option value=""></option>
<option value="Inadequate Training">Inadequate Training</option>
<option value="Inadequate Tools">Inadequate Tools</option>
<option value="Distracted">Distracted</option>
<option value="OTHER">Other</option>
<td><input type="text" name="meetingsubject" size=50 id="meetingsubject" /></td>

</tr>

<tr>
<td align="left">22. Eyes on Path</td>
<td><select name="q22answer" id="q22answer">
<option value="N/A">N/A</option>
<option value="SAFE">SAFE</option>
<option value="AT RISK">AT RISK</option>
</select>
</td>
<td><select name="Comment22" id="Comment22">
<option value=""></option>
<option value="Inadequate Training">Inadequate Training</option>
<option value="Inadequate Tools">Inadequate Tools</option>
<option value="Distracted">Distracted</option>
<option value="OTHER">Other</option>
<td><input type="text" name="meetingsubject" size=50 id="meetingsubject" /></td>

</tr>

<tr>
<td align="left">23. Eyes on Work</td>
<td><select name="q23answer" id="q23answer">
<option value="N/A">N/A</option>
<option value="SAFE">SAFE</option>
<option value="AT RISK">AT RISK</option>

</select>
</td>
<td><select name="Comment23" id="Comment23">
<option value=""></option>
<option value="Inadequate Training">Inadequate Training</option>
<option value="Inadequate Tools">Inadequate Tools</option>
<option value="Distracted">Distracted</option>
<option value="OTHER">Other</option>
<td><input type="text" name="meetingsubject" size=50 id="meetingsubject" /></td>

</tr>

</tr>
</table><br>
<strong><em>
ENVIRONMENT:
</em></strong>
<table>

<tr>
<td align="left">24. Housekeeping</td>
<td><select name="q24answer" id="q24answer">
<option value="N/A">N/A</option>
<option value="SAFE">SAFE</option>
<option value="AT RISK">AT RISK</option>
</select>
</td>
<td><select name="Comment24" id="Comment24">
<option value=""></option>
<option value="Inadequate">Inadequate</option>
<option value="Incorrect">Incorrect</option>
<option value="OTHER">Other</option>
<td><input type="text" name="meetingsubject" size=50 id="meetingsubject" /></td>

</tr>

<tr>
<td align="left">25. Equipment</td>
<td><select name="q25answer" id="q25answer">
<option value="N/A">N/A</option>
<option value="SAFE">SAFE</option>
<option value="AT RISK">AT RISK</option>
</select>
</td>
<td><select name="Comment25" id="Comment25">
<option value=""></option>
<option value="Inadequate">Inadequate</option>
<option value="Incorrect">Incorrect</option>
<option value="OTHER">Other</option>
<td><input type="text" name="meetingsubject" size=50 id="meetingsubject" /></td>

</tr>

<tr>
<td align="left">26. Lighting</td>
<td><select name="q26answer" id="q26answer">
 &

Is This A Good Question/Topic? 0
  • +

Replies To: Html/ JavaScript form validation

#2 PennyBoki  Icon User is offline

  • system("revolution");
  • member icon

Reputation: 53
  • View blog
  • Posts: 2,334
  • Joined: 11-December 06

Re: Html/ JavaScript form validation

Posted 12 January 2007 - 09:13 PM

I beleave you'll find here the answers.

CLICK

This post has been edited by PennyBoki: 12 January 2007 - 09:14 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1