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 derfloh 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
Joined
Apr 5, 2005
Messages
16
Location
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!
 
When do you want to validate it? On blur? On submit of a form? What rule should it validatge against? Where does the rule come from? Does it ever change?

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
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