How to only allow predetermined values in textbox within an html form -


i have list of values want allowed entered text box within html form action take place. action taking end user web page. want end user enter values. can allowed enter else they'll receive notice/warning they've entered incorrect code.

three of predetermined list of values let's this

ggg01, ooo03 , mtm02

as said, , end user should allowed enter when enter 1 of 3 codes should taken specific web page. i've tried validation scripts , nothing seems working. i'm missing here , bet it's easy.

here's tried password field isn't working properly. please help. thank in advance.

<?xml version="1.0" encoding="utf-8"?>  <!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">   <head>     <title>       example validator     </title>     <style type="text/css" xml:space="preserve"> body, p,td{ font-family: arial,verdana,helvetica, sans-serif; font-size: 10pt } a{font-family: arial,verdana,helvetica, sans-serif;} b { font-family : arial, helvetica, sans-serif; font-size : 12px;   font-weight : bold;} .error_strings{ font-family:verdana; font-size:10px; color:#660000;} </style><script language="javascript" src="gen_validatorv4.js"     type="text/javascript" xml:space="preserve"></script>   </head>   <body>     <form action="" name="myform" id="myform">       <table cellspacing="2" cellpadding="2" border="0">         <tr>           <td align="right">             first name           </td>           <td>             <input type="text" name="firstname" />           </td>         </tr>         <tr>           <td align="right">             last name           </td>           <td>             <input type="text" name="lastname" />           </td>         </tr>         <tr>           <td align="right">             email           </td>           <td>             <input type="text" name="email" />           </td>         </tr>         <tr>           <td align="right">             password           </td>           <td>             <input type="text" name="pwd1" />           </td>         </tr>         <tr>           <td align="right">             address           </td>           <td>             <textarea cols="20" rows="5" name="address"></textarea>           </td>         </tr>         <tr>           <td align="right">             country           </td>           <td>             <select name="country">             <option value="" selected="selected">               [choose yours]             </option>             <option value="008">               albania             </option>             <option value="012">               algeria             </option>             <option value="016">               american samoa             </option>             <option value="020">               andorra             </option>             <option value="024">               angola             </option>             <option value="660">               anguilla             </option>             <option value="010">               antarctica             </option>             <option value="028">               antigua , barbuda             </option>             <option value="032">               argentina             </option>             <option value="051">               armenia             </option>             <option value="533">               aruba             </option></select>           </td>         </tr>         <tr>           <td align="right"></td>           <td>             <div id="myform_errorloc" class="error_strings">             </div>           </td>         </tr>         <tr>           <td align="right"></td>           <td>             <input type="submit" value="submit" />           </td>         </tr>       </table>     </form><script language="javascript" type="text/javascript"     xml:space="preserve">//<![cdata[ //you should create validator after definition of html form      function docustomvalidation() {   var frm = document.forms["myform"];   if(frm.pwd1.value != frm.pwd2.value)   {     sfm_show_error_msg('the password , verified password not match!',frm.pwd1);     return false;   }   else   {     return true;   } }    frmvalidator.setaddnlvalidationfunction(docustomvalidation); //]]></script>   </body> </html> 

i'm taking we're looking options without connecting database (that make answer longer). start off on direction , 1 particular option (which might not favorable or efficient option situation):

firstly, form tag should have method attribute.

<form action="confirm.php" method="post" name="myform" id="myform"> 

then can access , make conditional statements later on. example, if person typed in word wanted in lastname section , submitted it, can let go confirm.php include following script (which evaluate if user put in value or not, , depending on value, user redirected different page):

if ($_post['lastname']=="ggg01"){     header("nameofnewwebsite.php"); }else{     header("nameofanotherwebsite.php"); } 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -