Rabu, 15 April 2009

validitas



D' CRIPT
<html>
<head>
<title>Another way of using the general validation function </title>
</head>
<SCRIPT language="JavaScript1.2" src="gen_validation.js"></SCRIPT>
<body>
<P align=center>
<SCRIPT language="JavaScript1.2">
arrFormValidation = new Array();
idx=0;
</SCRIPT>
<form action="" onSubmit="return validateForm(this,arrFormValidation);">
<table cellspacing="2" cellpadding="2" border="0">
<tr>
<td align="right">First Name</td>
<td><input type="text" name="FirstName">
<SCRIPT language="JavaScript1.2">
// Create Array of validation objects for this input item
arrFormValidation[idx++] =
[
["maxlen=25",// Validation description - allow max of 25 chars
"First Name should be 25 characters max"+
"(Consider changing your Name !)"],

["required",// Required field
"Please Enter your First Name "+
"[Contact support if you don't have one!]"],

["alpha",// alphabetic
"Only alphabetic characters expected in "+
"your First Name "]
];
</SCRIPT>
</td>
</tr>
<tr>
<td align="right">Last Name</td>
<td><input type="text" name="LastName">
<SCRIPT language="JavaScript1.2">
arrFormValidation[idx++] =
[
["maxlen=25"],
["req","Please give your Last Name"],
["alpha"]
];
</SCRIPT>
</td>
</tr>
<tr>
<td align="right">EMail</td>
<td><input type="text" name="Email">
<SCRIPT language="JavaScript1.2">
arrFormValidation[idx++] =
[
["maxlen=50"],
["minlen=1","Please Give Your EMail(We will Never SPAM!)"],
["email"]
];
</SCRIPT>
</td>
</tr>
<tr>
<td align="right">Phone</td>
<td><input type="text" name="Phone">
<SCRIPT language="JavaScript1.2">
var phone_error=" Phone Number should be 6 digit ";
arrFormValidation[idx++] =
[
["num"],
["lessthan=999999",phone_error],
["greaterthan=111111",phone_error]
];
</SCRIPT>
</td>
</tr>
<tr>
<td align="right">Address</td>
<td><textarea cols="20" rows="5" name="Address"></textarea>
<SCRIPT language="JavaScript1.2">
arrFormValidation[idx++] =
[
["maxlen=500"]
];
</SCRIPT>
</td>
</tr>
<tr>
<td align="right">Country</td>
<td>
<SELECT name="Country">
<option value="" selected>[choose yours]
<option value="008">Albania
<option value="012">Algeria
<option value="016">American Samoa
<option value="020">Andorra
<option value="024">Angola
<option value="660">Anguilla
<option value="010">Antarctica
<option value="028">Antigua And Barbuda
<option value="032">Argentina
<option value="051">Armenia
<option value="533">Aruba
</SELECT>
<SCRIPT language="JavaScript1.2">
arrFormValidation[idx++] =
[
["dontselect=0","Please Select your country"]
];
</SCRIPT>
</td>
</tr>
<tr>
<td align="right"></td>
<td><input type="submit" value="Submit"></td>
</tr>
</table>
</form>
</P>
</body>
</html>

Tidak ada komentar: