Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exact phrase validation

Status
Not open for further replies.

GoGz

Technical User
Apr 5, 2005
16
0
0
HR
Hi!

I have a form in html document, and in one box should be entered exact phrase (lika a correct answer). That box should be validated, but I really don't know how to do that...

Thnx for your help!
 
It should be validated on submit... I don't understand that about the rule... It's like this - the correct answer is Heaven and it should be entered. If anything else (or nothing) is entered, then the warning should appear...
 
Code:
<HTML>
<HEAD>
<SCRIPT Language="Javascript">
function checkanswer(){
var strAnswer = document.forms["form1"].elements["answer"].value;
strAnswer = strAnswer.toUpperCase();
if(strAnswer == "HEAVEN"){
  alert("That's correct!");
  } else {
  alert("Sorry... wrong!");
  }
</SCRIPT>


</HEAD>
<BODY>

<FORM name="form1">
What is the opposite of hell? <input type="text" name="answer" size="20">
<br>
<input type="button" value="Check Answer" onClick="checkanswer();">
</FORM>
</BODY>
</HTML>

Just my 2¢

"In order to start solving a problem, one must first identify its owner." --Me
--Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top