I've been playing around with the following code with a view to using it as a simple password protection for a web page. All works OK but when I put it through the W3C validator it throws up the following error -
Line 41, Column 38: required attribute "action" not specified
<form name="password1" id="password1">User name <input type="text" name="usernam
The attribute given above is required for an element that you've used, but you have omitted it. For instance, in most HTML and XHTML document types the "type" attribute is required on the "script" element and the "alt" attribute is required for the "img" element.
Typical values for type are type="text/css" for <style> and type="text/javascript" for <script>.
The code is below:
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> <html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\"> <head> <meta name=\"generator\" content=\"HTML Tidy for Linux (vers 6 November 2007), see www.w3.org\" /> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /> <meta name=\"keywords\" content=\"\" /> <meta name=\"description\" content=\"\" /> <title>untitled</title>
<script type=\"text/javascript\"> </script> </head> <body> <div id=\"grlogon\"><script type=\"text/javascript\"> //<![CDATA[ //Encrypted Password script- By Rob Heslop //Script featured on Dynamic Drive //Visit http://www.dynamicdrive.com
function submitentry(){ password = document.password1.password2.value.toLowerCase() username = document.password1.username2.value.toLowerCase() passcode = 1 usercode = 1 for(i = 0; i < password.length; i++) { passcode *= password.charCodeAt(i); } for(x = 0; x < username.length; x++) { usercode *= username.charCodeAt(x); } //CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD if(usercode==16236794340&&passcode==15104439608832) //CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD { window.location=password+\".html\"} else{ alert(\"password/username combination wrong\")} } //]]> </script> ** LINE 41 --->> <form name=\"password1\" id=\"password1\">User name <input type=\"text\" name=\"username2\" size=\"15\" /><br /> Password<span class=\"style26\">.</span> <input type=\"password\" name=\"password2\" size=\"15\" /> <input type=\"button\" value=\"Submit\" onclick=\"submitentry()\" /></form> </div> </body> </html>
Propbably my lack of experience and understanding so any help appreciated
Where does this form submit it's information to? itself?
<form name="password1" id="password1">
needs to have an "action=..." attribute like this:
<form name="password1" id="password1" action="">
If you leave it blank (like above), it should submit to itself. (That's most likely what happens when you don't have an action specified.) You can tell it a page to submit to like this:
I've been playing around with the following code with a view to using it as a simple password protection for a web page. All works OK but when I put it through the W3C validator it throws up the following error -
The code is below:
<form name="password1" id="password1">
needs to have an "action=..." attribute like this:
<form name="password1" id="password1" action="">
If you leave it blank (like above), it should submit to itself. (That's most likely what happens when you don't have an action specified.) You can tell it a page to submit to like this:
<form name="password1" id="password1" action="/folder/page.php">
Make sense?
Thanks for the reply - yes, makes sense and amended script works and has no validation error.
John C