Why won't Netscape do the intended in the following? IE is able to
render this page as intended. It is is a "self-posting" ASP form with a
JavaScript validation function: if the form fails the JavaScript
validation function, then the form should not post and an alert should
be issued as indicated below.
The *first* alert in the Validate function works in NS, but the rest of
the code does not and therefore I wonder about the way I am referencing
the controls...trie d to experiment with this, as can be seen in the
rem'd out code. Tried to research in my books...
Thanks for any and all! Jules
---------------------------------------------------------------------------------------------------------------
<%Option Explicit%>
<%
'This is a self-posting form: the same form is used for both
'the request and response objects
If not IsEmpty(request .Form("txtFirst Name")) and _
Not IsEmpty(Request .Form("txtLastN ame")) then
'the form has been filled out and a brief thank you is sent
%>
<html>
<head>
<title>Thank You</title>
</head>
<body>
Thank you
<br><%=Request. Form("txtFirstN ame")%> <%= Request.Form("t xtLastName")%>
for your information.
Have a nice day!
</body>
</html>
<%Else%>
<!--Form has not been filled out, so provide it!-->
<html>
<head>
<script language="javas cript">
function trim(strField){
alert("trim");
return strField.replac e(/^\s+/,'').replace(/\s+$/,'')
}
function validate()
{
alert("validate ");
//if(document.all .txtFirstName.v alue == "" ||
document.all.tx tLastName.value == "")
if(trim(documen t.forms("frmInf o").elements("t xtFirstName").v alue) ==
"" || trim(document.f orms("frmInfo") .elements("txtL astName").value ) ==
"")
//document.swOrde r.elements[0].value
//if(trim(documen t.frmInfo.eleme nts[0].value == "" ||
trim(document.f rmInfo.elements[1].value) == "")
{
document.frmInf o.reset();
alert("Please enter both first and last names.");
return false;
}
document.frmInf o.submit();
return true;
}
</script>
<title>Thank You</title>
</head>
<body>
Please fill out this form:
<form name="frmInfo" action="AllCont rols.asp" method="post">
First Name: <input type="text" name="txtFirstN ame"><br>
Last Name: <input type="text" name="txtLastNa me"><br>
<input type="Button" value="Submit User Info" onclick="valida te()">
<input type="reset">
</form>
</body>
</html>
<%End if %>
render this page as intended. It is is a "self-posting" ASP form with a
JavaScript validation function: if the form fails the JavaScript
validation function, then the form should not post and an alert should
be issued as indicated below.
The *first* alert in the Validate function works in NS, but the rest of
the code does not and therefore I wonder about the way I am referencing
the controls...trie d to experiment with this, as can be seen in the
rem'd out code. Tried to research in my books...
Thanks for any and all! Jules
---------------------------------------------------------------------------------------------------------------
<%Option Explicit%>
<%
'This is a self-posting form: the same form is used for both
'the request and response objects
If not IsEmpty(request .Form("txtFirst Name")) and _
Not IsEmpty(Request .Form("txtLastN ame")) then
'the form has been filled out and a brief thank you is sent
%>
<html>
<head>
<title>Thank You</title>
</head>
<body>
Thank you
<br><%=Request. Form("txtFirstN ame")%> <%= Request.Form("t xtLastName")%>
for your information.
Have a nice day!
</body>
</html>
<%Else%>
<!--Form has not been filled out, so provide it!-->
<html>
<head>
<script language="javas cript">
function trim(strField){
alert("trim");
return strField.replac e(/^\s+/,'').replace(/\s+$/,'')
}
function validate()
{
alert("validate ");
//if(document.all .txtFirstName.v alue == "" ||
document.all.tx tLastName.value == "")
if(trim(documen t.forms("frmInf o").elements("t xtFirstName").v alue) ==
"" || trim(document.f orms("frmInfo") .elements("txtL astName").value ) ==
"")
//document.swOrde r.elements[0].value
//if(trim(documen t.frmInfo.eleme nts[0].value == "" ||
trim(document.f rmInfo.elements[1].value) == "")
{
document.frmInf o.reset();
alert("Please enter both first and last names.");
return false;
}
document.frmInf o.submit();
return true;
}
</script>
<title>Thank You</title>
</head>
<body>
Please fill out this form:
<form name="frmInfo" action="AllCont rols.asp" method="post">
First Name: <input type="text" name="txtFirstN ame"><br>
Last Name: <input type="text" name="txtLastNa me"><br>
<input type="Button" value="Submit User Info" onclick="valida te()">
<input type="reset">
</form>
</body>
</html>
<%End if %>
Comment