View Full Version : ASP Form Verification
phillip_ewing
03-04-2003, 02:42 AM
I am sure Whammy has answered this for me one time or the other but I will ask again becuase I forgot how to do it.
u_checked=ucase(trim(request.form("u_checked")))
' Check the box to see if checked
' then add to the display message
if (u_checked = "") and (u_submit <> "") then
message= message & "*Please enter agree to the terms and conditions<br>"
end if
<font size="1"><input type="checkbox" name="u_checked" value="ON"> I accept the <a href="terms.asp" target="_blank">service terms & conditions</a></font>
I cannot get that piece of code to verify. Any ideas??
Thanks, Phillip Ewing
glenngv
03-04-2003, 03:03 AM
you just assign a value to the message variable but you are not displaying its value. Is that the reason why you can't verify if the condition is correct?
phillip_ewing
03-04-2003, 03:47 AM
Below is the completed code for verification. I think the hardest part is verifying the checkbox.
u_checked=ucase(trim(request.form("u_checked")))
' Check the box to see if checked
' then add to the display message
if (u_checked = "") and (u_submit <> "") then
message= message & "*Please enter agree to the terms and conditions<br>"
end if
<font size="1"><input type="checkbox" name="u_checked" value="ON"> I accept the <a href="terms.asp" target="_blank">service terms & conditions</a></font>
response.write "<br><b>Agree to the terms and conditions: " & u_checked & "<br>"
MessageBody = MessageBody & "Agree to the terms and conditions: " & u_checked & vbCrLf
Thank you for your help in advance, Phillip Ewing
glenngv
03-04-2003, 04:47 AM
if the checkbox is not checked, u_checked is blank.
when are you displaying the value of the checked variable?
if (u_checked = "") and (u_submit <> "") then
message= message & "*Please enter agree to the terms and conditions<br>"
response.write message
end if
phillip_ewing
03-04-2003, 05:09 AM
I do not know how to check to see if it is checked or not. I do not understand how to do this.
Thanks, Phillip
tommysphone
03-04-2003, 02:48 PM
<select name="u_checked">
<option value="Select">Select</option>
<option value="Yes">Yes</option>
</select>
With this valifdation in the <head>
<script language="JavaScript">
function SubmitForm() {
var blnProblem = false;
var ptrForm = document.frmnamehere;
if(ptrForm.u_checked.value == "Select"){
alert("Please confirm you agree to the terms and conditions");
ptrForm.u_checked.focus();
return (false);
}
if(blnProblem == false) {
ptrForm.submit();
}
}
</script>
and this for the button
<input type="button" value="Send Details"
name="B1" class="NormalButton" onClick="SubmitForm()">
glenngv
03-05-2003, 03:29 AM
Originally posted by phillip_ewing
I do not know how to check to see if it is checked or not. I do not understand how to do this.
Thanks, Phillip
this is how you check if the checkbox is checked:
u_checked=request.form("u_checked")
if (u_checked = "") then
response.write "Checkbox is not checked"
else
response.write "Checkbox is checked"
end if
phillip_ewing
03-05-2003, 03:51 AM
glenngv,
I have attached my code. Can you please take a look at it? I copied it in there as instructed and it still failed. I am missing something and I just do not know what. Thank you in advance.
Thanks, Phillip Ewing
glenngv
03-05-2003, 04:16 AM
you are saying that it still did not work but you are not applying the idea of what i've been saying...
<%
...
u_checked=request.form("u_checked") 'no need to trim
if u_checked="" then
u_checked="NO"
strCheck = ""
else
strCheck = " checked"
end if
...
%>
...
<INPUT type="checkbox" name="u_checked" value="YES"<%=strCheck%>>
...
<%
...
response.write "<br><b>Agree to the terms and conditions: " & u_checked & "</b><br>" 'YES or NO
...
%>
whammy
03-06-2003, 04:11 AM
:)
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.