Refactor
:my
=>
'code'
Codes
Refactorings
Popular
Best
Submit
Spam
Account
Logout
Login
JavaScript doesn't seem to be activated, expect things to be ugly and sloppy!
Learn How to Create Your Own Programming Language
createyourproglang.com
Recent
Zynga Slingo Trainer v5.12
iTunes Gift Card Generator V3.1 2012
Diablo 3 GOLD Coins FREE
Working PS3 Jailbreak 3.65 And 3.66
ExtaBit Premium Accounts and Cookies
Steam Wallet Hack - Money Adder & Hack v3
Empires & Allies Hack Cheat Trainer v5.4.1
Eve Onnline 60 Days Time Card Generator v2
Xbox Lve Generator v3
Better way to get content via jQuery $.get()
Popular
XBOX POINTS GENERATOR - MICROSOFT POINTS GENERATOR v1.2012
11 may 2012 premium uploading accounts 100% working
Free Microsoft Points
Free Microsoft Points - Microsoft Points Generator - Xbox Live Codes 2012
Car Town Free Blue Points Hack
Free CarTown Blue Points Generator and CarTown Templates
Free Microsoft Points
Simple Days Purger
Sharecash Downloader Bypass Surveys New 05/2012
PAYPAL REMOVE ACCESS LIMITED ACCOUNT 100% Working
Pastable version of
Simple form validator with RegEx
<pre class='prettyprint' language='javascript'>//function that loops through the elements function __validateForm(theform){ numEle=theform.elements.length; for(i=0;i<numEle;i++){ elem=theform.elements[i]; if(elem.alt){ parts=elem.alt.split("::"); regex=new RegExp(parts[0],'i'); if(!regex.test(elem.value)){ alert(parts[1]); return false; } } } return true; } //init function to bind the validation to the onsubmit //can take an argument, that is a function for extra validation function validateForm(){ var vaditional; if(!arguments.length){ f=function(){ return __validateForm(this); } }else{ vaditional=arguments[0]; f=function(){ ret=__validaForm(this); if(ret) return vaditional(this); return false; } } return f; }</pre> <pre class='prettyprint' language='javascript'><html> <script> function init(){ document.forms.registro.onsubmit=validateForm(); } window.onload=init; </script> <body> <form name="registro" id="registro" action="procesa_login.html" method="post"> <fieldset> <legend>Login</legend> <p>Username:</p> <input type="text" name="usuario" alt="^[a-z0-9_-]{4,12}$::Specifie a username between 4 and 12 alfanumeric character. No whit space allowed" /> <p>Password:</p> <input type="password" name="password" alt="^.{4,12}$::Introduce a password between 4 and 12 characters" /> </fieldset> <input type="submit" name="submit" value="Enviar" /> </form> </body> </html></pre> <pre class='prettyprint' language='javascript'><html> <script> //in this case we use a function to compare the two passwords fields function comparePasswords(theform){ if(theform.password.value!=theform.repassword.value){ alert('The two passwords are not equel'); return false; } return true; } function init(){ //we atach the comparePasswords to the validateForm document.forms.registro.onsubmit=validateForm(comparePasswords); } window.onload=init; </script> <body> <form name="registro" id="registro" action="procesa_login.html" method="post"> <fieldset> <legend>Login</legend> <p>Username:</p> <input type="text" name="usuario" alt="^[a-z0-9_-]{4,12}$::Specifie a username between 4 and 12 alfanumeric character. No whit space allowed" /> <p>Password:</p> <input type="password" name="password" alt="^.{4,12}$::Introduce a password between 4 and 12 characters" /> <p>Reenter Password:</p> <input type="password" name="repassword" /> </fieldset> <input type="submit" name="submit" value="Enviar" /> </form> </body> </html></pre> <a href="http://www.refactormycode.com/codes/149-simple-form-validator-with-regex" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://www.refactormycode.com/images/small_logo.gif" style="border:0" /></a>