DIT-OI4-0356/2007 Cat - One Web - Dev (Ii) Discuss Four Validations Citing The Four Different Types of Form Validation (Using Code Examples)
DIT-OI4-0356/2007 Cat - One Web - Dev (Ii) Discuss Four Validations Citing The Four Different Types of Form Validation (Using Code Examples)
CAT – ONE
Discuss four validations citing the four different types of form validation (using code examples)
Email validation
Value validation
Digit validation
Empty validation
You can either validate each field whenever it is changed or you can validate all fields at one time when
the submit button is clicked.
1. Email validation(this,text)
Checking if the content has the general syntax of an email.
Optional parameters are:
text--text that will show in an alertbox if content is illegal.
<html>
<head>
<title><b><u>Email Validation </b></u>
</title>
</head>
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
lastpos=value.length-1;
if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2)
{if (alertbox) {alert(alertbox);} return false;}
else {return true;}
}
}
</body>
</html>
2.Value validation(this,min,max,text,type)
Checking if the content is a number in a limited area.
Optional parameters are:
min --minimum value allowed in the field.
max --maximum value allowed in the field.
text --text that will show in an alertbox if content is illegal.
type --enter "I" if only integers are allowed.
html>
<head>
<title><b><u>Value validation</b></u>
</title>
</head>
html>
<head>
<title><b><u>Bedtra Tours and Safaris intranet</b></u>
</title>
</head>
4.Empty validation(this,text)
Checking if the field is empty.
Optional parameters are:
text --text that will show in an alertbox if content is illegal.
html>
<head>
<title><b><u>Bedtra Tours and Safaris intranet</b></u>
</title>
</head>