Solved

HTML Code help

Posted on 2013-05-09
12
331 Views
Last Modified: 2013-12-24
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
Comment
Question by:dashman
  • 3
  • 3
  • 2
  • +1
12 Comments
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 39154567
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
 

Author Comment

by:dashman
ID: 39155113
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
 
LVL 82

Expert Comment

by:leakim971
ID: 39155696
please provide a link to see the page
0
 

Author Comment

by:dashman
ID: 39155759
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 82

Expert Comment

by:leakim971
ID: 39155811
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
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 39156190
As it says in the "View Source" of your page, the javascript is generated by Frontpage and is not directly editable in Frontpage.
0
 

Author Comment

by:dashman
ID: 39156512
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
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 39156571
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
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 39157607
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

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now