• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 374
  • Last Modified:

HTML Code help

I need to have a line in my code that requires a response and I want that response to be the answer to a question before the user can "submit" a form to the owner of the questionare.

Example: what is the sum of 6 + 3? It should be a required field and the answer has to be 9 before the user can successfully hit the "submit" button to send the form.

Below is what I have so far

Thanks for your help

</select>&nbsp; <strong>*What is the sum of 6 + 3?:</strong>

<!--webbot bot="Validation" b-value-required="TRUE" --><input type="text" name="Answer" size="7"><p>&nbsp;</p>

<div align="center"><center><p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
0
dashman
Asked:
dashman
  • 3
  • 3
  • 2
  • +1
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
You could user javascript to do that validation.  I don't know what the 'webbot' code does.  But I must tell you that most spammers will skip your form and submit spam directly to your action page.  You must also validate input on your action page to keep spam out.

What does that mean?  If I look at the "View Source" of your page, I can read the action="xx.php" address you are sending the info to.  Then I can simply make up a form on my computer that submits info directly to that page without going thru your form.
0
 
dashmanAuthor Commented:
I appreciate your response. I am trying to help out a friend with his website. Someone else originally wrote the javascript code. I am familiar with html but not javascript. I understand what you are saying about making up a form but that is not what the bot is doing. I need to have a field that they have to answer correctly. I have looked at some Captcha sites but cannot seem to get any to work. I was hoping for something a little easier but I guess that might be hard to find.

I did look at the form page source and found this line of code. He is using Frontpage (I know that is outdated but we had been able to make all the changes we needed with it) and see that if we could make it read "does not equal 9 then return false" that would do it.. When I look at the html code in Frontpage I do not see the javascript code so I do not know how you access that to change it.

if (theForm.Answer.value == "")
  {
    alert("Please enter a value for the \"Answer\" field.");
    theForm.Answer.focus();
    return (false);
0
 
leakim971PluritechnicianCommented:
please provide a link to see the page
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
dashmanAuthor Commented:
0
 
leakim971PluritechnicianCommented:
http://www.neusob.de/projekt/workshop/webbot.htm

I think you need help from an other zone :
http://www.experts-exchange.com/Web_Development/Software/FrontPage/

Try to change the zone of your question or request attention of a moderator (there's a link somewhere in this page)
0
 
Dave BaldwinFixer of ProblemsCommented:
As it says in the "View Source" of your page, the javascript is generated by Frontpage and is not directly editable in Frontpage.
0
 
dashmanAuthor Commented:
then how do you edit the javascipt and how would you change it to make it a set value? I think you can see that I am a novice at this aspect (been an IT consultant for 20 years) and could use all the help I can get.

Thanks
0
 
Dave BaldwinFixer of ProblemsCommented:
You would have to stop using Frontpage and do the editing manually.  Wait and see if anyone from the Frontpage zone has another suggestion.
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
You could use http://www.google.com/recaptcha/captcha

However, I do the same thing you are doing for smaller sites.   I would not use js unless you are using to post to another page (ajax) where that page is testing serverside. Otherwise, the way this works is you create your answer serverside before the page loads and store the answer in a session.  Then allow t he form to post and test for the answer and if the answer is not correct, send them back to the form.  To make it easy for your user, save the form answers and write them back to the form fields so they don't have to type them in again.  I also keep a counter in a session and after the counter goes past a number like 3 or 4, make them start over or prevent the page from loading.  Of course when the session resets or they close their browser they can try again.  

Here it is quickly in asp since you are using front page
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
' --- this function makes a random number 1 to 10
function rNumber()
max=10
min=1
Randomize
rNumber=(Int((max-min+1)*Rnd+min))
end function

x=rNumber ' the function makes the first number
y=rNumber ' the function makes the 2nd number
question="what is "&x&" + "&y
session("answer")=x+y

%>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Request an Appointment</title>
</head>
<!-- your code -->
<form>
<!-- your form code -->
  </select>&nbsp; <strong>To assure that a human is filling out this form please answer the following question:</strong>
  </select>&nbsp; 
<!--  ****** your new question code **** -->
<strong>*<%=question%></strong>
<!--  ****** end your new question code **** -->
  <!--webbot bot="Validation" b-value-required="TRUE" --><input type="text" name="Are_you_a_human" size="7"></p>

</form>
<body>

Open in new window

Then on the page where you process your code at the top of the page
<%
if cstr(request.form("Are_you_a_human"))<>cstr(session("answer")) then
     response.redirect("appointment.htm")
end if

%>

Open in new window

You can do this just as easy in php or any serverside language.  If you want to keep the page as html, then you would put the server side code on a separate asp page and use ajax to call the info.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now