Set up a global variable counter = 3. Each failed attempt deduct 1 and show an alert (""You have " + counter " tries left");. If counter <=0 show alert ("You have run out of attempts"); and return false (stop execution).
This must be homework. Of course, after the 3 tries the user can simply reload the page and get another 3 goes. That is if he is too unknowing to use View Source. As devnull69 says, security quotient: 0.
<form action="name" // what is that supposed to be?
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Last edited by Philip M; 02-21-2012 at 11:52 AM..