[Javascript] Validating form elements on an Edit form
KSLowers
kslowers at tampabay.rr.com
Sat Jul 5 20:49:52 CDT 2003
Hello
I trying to learn how to re-validate modified data within an Edit form.
Everything works well, as far as the 'asked for' data appearing as it
should. But when I modify the data, then resubmit it nothing happens. I'm
not sure what I'm missing and/or understanding. I have a sample of the code
below, and a copy of the file if you want to see how far I've got. Can
someone show me what to do? Kinda burn-out on this one. Thanks in advance
for your help.
Kevin
==============
<script Language="JavaScript">
<!--
function Form_Validator(theForm){
// 1. Check if pcr number field is blank
if (theForm.PcrNo.value == ""){
alert("Please enter a value for the \"PcrNo\" field.");
theForm.PcrNo.focus();
return false;
}
if (theForm.PcrNo.value != "ADMIN"){
alert("Error: A pcr number cannot contain both letters and numbers.");
theForm.PcrNo.focus();
return false;
}
if (theForm.PcrNo.value != "ETO"){
alert("Error: A pcr number cannot contain both letters and numbers.");
theForm.PcrNo.focus();
return false;
)
if (theForm.PcrNo.value != "SICK"){
alert("Error: A pcr number cannot contain both letters and numbers.");
theForm.PcrNo.focus();
return false;
}
}
</script>
<body>
<FORM method=POST
action="http://localhost/Webpages/HoursTrackingLog/HtlEditSe.asp?id=<%=iReco
rdId%>" onSubmit="return Form_Validator(this)" id=form name="myform">
<P><FONT face=Verdana><FONT size=2><B>PCR NO./PL</B></FONT> </FONT>
<INPUT id=text1 style="LEFT: 60px; WIDTH: 86px; TOP: 16px; HEIGHT: 22px"
size=12 name=PcrNo value=<%=rs("Pcr")%>></P>
<P><FONT face=Verdana><FONT size=2><B>WEEKDAY</B></FONT>
<INPUT type="text" name=DATE value=<%=rs("WeekDay")%>><A
OnClick=ShowDate()>
<IMG align=top border=0 height=25 id=dimg1 src="./graphics/calendar.gif"
width=26 Title="Quick Calendar"></A>
<P><FONT face=Verdana><FONT size=2><B>HOURS WORKED</B></FONT>
</FONT>
<INPUT id=text3 style="WIDTH: 63px; HEIGHT: 22px" size=9 name=HrsWorked
value=<%=nHrs%>></P>
</body>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: htlEdit.asp
Type: text/asp
Size: 7761 bytes
Desc: not available
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20030705/b1d89d10/attachment.bin>
More information about the Javascript
mailing list