Extreme Form Field Validator

JavaScriptBank

Bannato
26 Nov 2009
86
0
0
Handle and precess all of your form field validations using just one script. This JavaScript can verify numeric strings; monitor the detail at JavaScriptBank.com - 2.000+ free JavaScript codes


How to setup

Step 1: Copy & Paste CSS code below in your HEAD section
CSS
Codice:
<style>
#errordiv {
  border: 1px solid red;
  background-color: #FFAFAF;
  display: none;
  width: 50%;
  margin: 5px;
  padding: 5px;
}

.required {
  background-color: #CC4444;
}

.required:focus {
  background-color: #fff;
  border: 1px solid #f00;
}

.checkit {
  background-color: #E0E5EF;
}
</style>

Step 2: Place JavaScript below in your HEAD section
JavaScript
Codice:
<script type="text/javascript" src="chkform.js"></script><script type="text/javascript">
function configureValidation(f,alerttype){
  f.firstname.isAlphaNumeric = true;
  f.lastname.isAlphaNumeric = true;
  f.email.isEmail = true;
  f.phone.isPhoneNumber = true;
  f.birthday.isDate = true;
  f.postalcode.isEmpty = true;
  f.password1.isLengthBetween = [4,255];
  f.password2.isMatch = f.password1.value;
  f.comments.optional = true;
  var preCheck = (!f.infohtml.checked && !f.infocss.checked && !f.infojs.checked) ? errormsg[0] : null;
  return validateForm(f, preCheck, 'required', alerttype);
}
</script>

Step 3: Copy & Paste HTML code below in your BODY section
HTML
Codice:
<div>
<form action="#" method="post" onsubmit="return configureValidation(this,3)" onreset="confirm(errormsg[99])">
<table class="formtable">
<tr>
<td>First Name:</td>
<td><input class="checkit" type="text" id="First name" name="firstname" value="" class="text"></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input class="checkit" type="text" id="Last name" name="lastname" value="" class="text"></td>

</tr>
<tr>
<td>Email:</td>
<td><input class="checkit" type="text" id="Email" name="email" value="" class="text"></td>
</tr>
<tr>
<td>Email Preferred:</td>
<td><select name="emailpreferred">
<option value="text">Text</option>
<option value="html">HTML</option>
<option value="flash">Flash</option>
</select></td>

</tr>
<tr>
<td>Phone: (US only) </td>
<td><input class="checkit"  type="text" id="Phone" name="phone" value="000-000-0000" class="text"></td>
</tr>
<tr>
<td>Birthday:</td>
<td><input class="checkit"  type="text" id="Birthday" name="birthday" value="mm-dd-yyyy" class="text"></td>
</tr>
<tr>
<td>Gender:</td>
<td>Male:<input type="radio"  name="gender" value="male" class="radio" checked="checked"> Female:<input type="radio" name="gender" value="female" class="radio"></td>

</tr>
<tr>
<td>Password:</td>
<td><input class="checkit" onKeyPress="checkCapsLock( event )" id="Password" type="password" name="password1" value="" class="text"></td>
</tr>
<tr>
<td>Re-Enter:</td>
<td><input class="checkit" onKeyPress="checkCapsLock( event )" id="Password again" type="password" name="password2" value="" class="text"></td>
</tr>
<tr>
<td>Postal Code</td>
<td><input class="checkit" name="postalcode" type="text" id="Postal code" onKeyPress="javascript:checkNumber(this);" onKeyUp="javascript:checkNumber(this);"></td>
</tr>
<tr>

<td colspan="2">Select one or more of the following:</td>
</tr>
<tr>
<td colspan="2">HTML:<input type="checkbox" name="infohtml" value="true" class="checkbox"> CSS:<input type="checkbox" name="infocss" value="true" class="checkbox"> JavaScript:<input type="checkbox" name="infojs" value="true" class="checkbox"></td>
</tr>
<tr>
<td>Comments:</td>
<td><textarea id="Comment" name="comments" class="text" cols="20" rows="4"></textarea></td>
</tr>

</table>
<div id="errordiv"> </div>
<div>
<input type="submit" name="submit" value="Submit" class="button"> <input type="reset" name="reset" value="Reset" class="button"></td>
</form>
</div>

Step 4: downloads
Files
chkform.js






 
Discussioni simili
Autore Titolo Forum Risposte Data
A airport extreme e range range extender Reti LAN e Wireless 2
C Airport extreme fasteweb Adsl e Connettività 1
S passare un valore da un form a un file .php con metodo post PHP 4
K Form che manda dati doppi PHP 1
K Problema form update PHP 2
Elisacau [Contact form 7] Inserire Numero auto incrementante WordPress 1
K form Inserimento record mysql PHP 2
I Form con selettore HTML e CSS 0
K [php]form invio dati PHP 0
G form invio multiplo con checkbox PHP 12
nivaria.achinet Intercettare form solo dopo invio Javascript 1
D Form contatti non funzionante HTML e CSS 0
A Stampare dati da form PHP 15
M Unire 2 funzioni per l'invio di un form e con l'apertura di un div Javascript 0
I Form HTML e CSS 17
otto9due $_FILE non passa i dati dal form PHP 1
M Form: come tornare ai campi già compilati dopo invio PHP 1
G Invio form con PHP PHP 3
felino Form action costum e parametri in queryString WordPress 1
M Come recuperare molteplici input form PHP 1
M Collegamento tra form html e script php PHP 4
L form immagini per il database PHP 0
A form PHP prenotazione tramite query PHP 2
A Form php prenotazione di un azienda sanitaria locale presso studio medico PHP 1
L inserimento form dati multipli ? PHP 0
L Problemi form Pagina php HTML e CSS 3
Cosina Creare bottone delete in form upload PHP 5
Cosina Creare bottone delete in form upload PHP 1
D Devo far funzionare un form di contatti PHP 4
B form gestione input PHP 2
V PHP form intersecate PHP 0
8 Javascript - PDF Form Javascript 0
J Form inserimento dati in database Ajax 1
E Gestione profilo utente tramite Form PHP 3
R [C#] Form principale si blocca mentre un altro Thread lavora .NET Framework 0
M Problema con controllo form in real time jQuery 6
D Form validazione Javascript 2
R form recovery pass PHP 0
V Symfony e i form PHP 3
M form con checkbox PHP 8
S come aggiustare un form di contatto? HTML e CSS 3
F query e form con select multipla PHP 17
MarcoGrazia Verifica di una stringa o di un nome proveniente da form Snippet PHP 0
A Inserimento dati nel database tramite form + altre operazioni PHP 18
websilvia Contact form using Bootstrap 3.3.4 PHP 8
Alex_70 Button non funziona nella form PHP 2
C Form email php su pagina index.html? PHP 21
W Rinominare Documenti Con Form Asp Classic ASP 9
S Invio email da form PHP 8
L form multipla php sql,errore in inserimento MySQL 0

Discussioni simili