Write Javascript code to validate a registration number of a vehicle. The code
has to be able to accept the registration number as a string, checks whether th
format is valid and displays the province that the vehicle has been registered
by reading the two alpha characters at the beginning. (as given in Figure 1)
Example: valid format - CPNA-8130 - (four characters - four digits) Centra
Province.
function validate(){
var valid = false;
var v = document.getElementById("regNo").value;
if(!(v== "")@@ (v.length < 9)) {
alert("Please Enter Registration Number");
valid = false;
}
else
{
var a = v.split("-");
var pro = a.substring(0,2);
if(pro=="cp"){
alert("Central Province");
valid = true;
}
if(pro=="wp"){
alert("Western Province");
valid = true;
}
}
mage answer eka poddak hari shape da ..?? plzz help ekak denawada ...
thnkuu
has to be able to accept the registration number as a string, checks whether th
format is valid and displays the province that the vehicle has been registered
by reading the two alpha characters at the beginning. (as given in Figure 1)
Example: valid format - CPNA-8130 - (four characters - four digits) Centra
Province.
function validate(){
var valid = false;
var v = document.getElementById("regNo").value;
if(!(v== "")@@ (v.length < 9)) {
alert("Please Enter Registration Number");
valid = false;
}
else
{
var a = v.split("-");
var pro = a.substring(0,2);
if(pro=="cp"){
alert("Central Province");
valid = true;
}
if(pro=="wp"){
alert("Western Province");
valid = true;
}
}
mage answer eka poddak hari shape da ..?? plzz help ekak denawada ...
thnkuu

Last edited: