Understanding ValidationAs it name suggests is a validation process to ensure that it
which is intended to be true. But this is not easy to do. In the application of e-commerse validation is absolute, the transaction should be accounted for and must be true. There must be no adverse events traksaksi others. However this is not good and we still have to try so this does not happen. This is one important validation. In the cyber world people are free to do anything. Includes fun (try-try) this validation problem. Before we know most of us are familyer with computers ever do this. For example, a computer with the password that we do not know the password then we try to enter the word into the form hoping password will be true, or just send data one done repeatedly so that it will spend a space and add slow computer work. Basically the validation of a web-based application can be distinguished into two kinds. Ie validation of client side and server side validation.
Validation of client sideValidation of client side validation is performed diclient means pengercekan (browser) before the data is sent to the server for processing. This method has several advantages, among others, is the speed of access, because it is not sent to the server then the validation can be done quickly, but still not good enough for accuracy, because this method is only able to check the truth according to the format or request but have not been able to check the conformity with the database. The usual method used for checking the simple things. Eg date form, email, phone, zipcode and others. Because these checks on the client side language used is also a client-based language such as Java Script Perl VB Script. On this occasion we will use java script for form validation. Form input validation is used to evaluate the contents of the form of the error form filling. Here's an example of form validation is done on the client side (browser):
<html>
<head>
<title>.::Penggunaan Validasi Input Form::.</title>
<script language="javascript">
function validasi()
{
var panjang = (form1.nim.value).length;
if ((panjang < 8) || (panjang > 8))
alert("Jumlah Karakter pada NIM masih salah");
else if (isNaN(form1.nim.value))
alert("NIM haruslah berupa bilangan 8 digit");
else if ((form1.mail.value).indexOf('@',1) < 1)
alert("Penulisan Alamat Email masih Salah");
else
form1.submit();
}
</script>
</head>
<body>
<pre>
<form method="get" name="form1" action="valid.asp">
Nama : <input type="text" name="nama" maxlength="20"
onKeypress="if ((event.keyCode >= 33 && event.keyCode <=
64)||(event.keyCode >= 91 && event.keyCode <= 96)) event.returnValue =
false;">
NIM : <input type="text" name="nim" maxlength="8"
onKeypress="if (event.keyCode < 45 || event.keyCode > 57)
event.returnValue = false;">
E-mail Address : <input type="text" name="mail" maxlength="30">
<input type="button" value="kirim" onClick="validasi()">
</form>
</pre>
</body>
</html>
Description:
- Field wearing onKeyPress function will be immediately validated when doing
input on the form in question.
- In validating java script is divided into 2 parts.
1. java script is placed in the function, where the function will be called
program during onClick action.
2. java script is placed diform. Java script will be between running at the time
when there is action on the form that has this functionality (onKeypress).
- Checking the contents of the new form will be made when there is an action against the
containing at least one form onKeypress function. If this dysfunction valid data to be entered, which will require validation with java script function onClick. Diruning results after this program as follows:
Description:
- Field name must be filled with letters and should be in the field nim with ankat
as many as 8 characters. If the above criteria are not met then the browser will give the wrong reaction only the alerts with new windows. For example: