<html>
<head>
<title>
Ele_bill </title>
<script
type="text/javascript">
function
chkForm()
{
pd=document.getElementById('t1').value;
pd1=document.getElementById('t2').value;
bno=document.getElementById('t3').value;
mno=document.getElementById('t4').value;
cn=document.getElementById('t5').value;
add=document.getElementById('t6').value;
pr=document.getElementById('t7').value;
pred=document.getElementById('t8').value;
cr=document.getElementById('t9').value;
curd=document.getElementById('t10').value;
unit=document.getElementById('t11').value;
rate=document.getElementById('t12').value;
//--------------Validation for
period-----------------------
if(document.getElementById('t1').value
=='')
{
alert("You must
enter bill period");
return false;
}
/*var a =
document.getElementById('t1').value;
if(isNaN(a)||a.indexOf("
")!=-1)
{
alert("Invalid bill
period");
return false;
}*/
if(document.getElementById('t2').value
=='')
{
alert("You must
enter period");
return false;
}
/*var b =
document.getElementById('t2').value;
if(isNaN(b)||b.indexOf("
")!=-1)
{
alert("Invalid bill
period");
return false;
}*/
//--------------Validation for bill
no-----------------------
if(document.getElementById('t3').value
=='')
{
alert("You must
enter bill no");
return false;
}
var c =
document.getElementById('t3').value;
if(isNaN(c)||c.indexOf("
")!=-1)
{
alert("Invalid bill
no");
return false;
}
//-----------------Validation for
meter no------------------
if(document.getElementById('t4').value
=='')
{
alert("You
must enter meter no");
return false;
}
var d =
document.getElementById('t4').value;
if(isNaN(d)||d.indexOf("
")!=-1)
{
alert("Invalid meter
no");
return false;
}
//--------------Validation for
customer name--------------
if(document.getElementById('t5').value
=='')
{
alert("You must
enter customer name");
return false;
}
if(cn)
{
for(var
i=0;i<cn.length;i++)
{
if(cn.charAt(i)
< 'A' || cn.charAt(i) > 'Z' && cn.charAt(i) <'a' ||
cn.charAt(i)>'z')
{
alert("Invalid
Text in customer name")
return
false;
}
}
}
//--------------Validation for
Address--------------
if(document.getElementById('t6').value
=='')
{
alert("You must
enter Address");
return false;
}
if(add)
{
for(var
i=0;i<add.length;i++)
{
if(add.charAt(i)
< 'A' || add.charAt(i) > 'Z' && add.charAt(i) <'a' ||
add.charAt(i)>'z')
{
alert("Invalid
Text in Address")
return
false;
}
}
}
//--------------validation for
previous reading-----------------
if(document.getElementById('t7').value
=='')
{
alert("You must
enter previous reading");
return false;
}
var pred =
document.getElementById('t7').value;
if(isNaN(pred)||pred.indexOf("
")!=-1)
{
alert("Invalid privious
reading");
return false;
}
//------------validation for
previous reading date----------
if(document.getElementById('t8').value
=='')
{
alert("You must
enter previous reading date");
return false;
}
/*var pvd =
document.getElementById('t8').value;
if(isNaN(pvd)||pvd.indexOf("
")!=-1)
{
alert("Invalid previous
reading date");
return false;
} */
//--------------validation for
current reading------------------
if(document.getElementById('t9').value
=='')
{
alert("You must
enter current reading");
return false;
}
var cred =
document.getElementById('t9').value;
if(isNaN(cred)||cred.indexOf("
")!=-1)
{
alert("Invalid current
reading");
return false;
}
//-------------------validation for
Current reading date---------
if(document.getElementById('t10').value
=='')
{
alert("You must
enter current reading date");
return false;
}
/*var curd =
document.getElementById('t10').value;
if(isNaN(curd)||curd.indexOf("
")!=-1)
{
alert("Invalid current
reading date");
return false;
} */
//--------------Validation for
Unit--------------
if(document.getElementById('t11').value
=='')
{
alert("You must
enter units");
return false;
}
var un = document.getElementById('t11').value;
if(isNaN(un)||un.indexOf("
")!=-1)
{
alert("Invalid units");
return false;
}
//-------------validation for rate
per unit-------------
if(document.getElementById('t12').value
=='')
{
alert("You must
enter rate");
return false;
}
var run =
document.getElementById('t12').value;
if(isNaN(run)||d.indexOf("
")!=-1)
{
alert("Invalid rate");
return false;
}
return true;
}
function
cal()
{
//----------------Calculate bill--------------
var unit=document.admin.t11.value
var rate=document.admin.t12.value
var amt=parseInt(unit*rate)
document.admin.t13.value=amt
}
</script>
</head>
<body>
<center>
Bill Processing </center>
<table
align="center">
<form
action="#" name="admin" id="admin">
<tr>
<td>
Billperiod: </td>
<td>
<input type="text" name="t1" id="t1"> To
<input type="text" name="t2" id="t2">
</td>
</tr>
<tr>
<td>
Bill number: </td>
<td>
<input type="text" name="t3" id="t3">
</td>
</tr>
<tr>
<td>
Meter no: </td>
<td>
<input type="text" name="t4" id="t4">
</td>
</tr>
<td>
Customer Name: </td>
<td>
<input type="text" name="t5" id="t5">
</td>
</tr>
<tr>
<td>
Address: </td>
<td> <input type="text"
name="t6" id="t6"> </td>
</tr>
<tr>
<td>
Customer type: </td>
<td>
<select> <option name="">mr </select> </td>
</tr>
<tr>
<td>
Previous Reading: </td>
<td>
<input type="text" name="t7" id="t7"> <input type="text"
name="t8" id="t8">
Date </td>
</tr>
<tr>
<td>
Current Reading: </td>
<td>
<input type="text" name="t9" id="t9"> <input type="text"
name="t10" id="t10">
Date </td>
</tr>
<tr>
<td>
Units: </td>
<td>
<input type="text" name="t11" id="t11">
</td>
</tr>
<tr>
<td>
Rate per unit: </td>
<td>
<input type="text" name="t12" id="t12"> Rs
</td>
</tr>
<tr>
<td>
Amount: </td>
<td>
<input type="text" name="t13" id="t13">
Rs</td>
</tr>
<tr>
<td>
Gross Amount: </td>
<td>
<input type="text" name="t14" id="t14">
Rs</td>
</tr>
<tr>
<td
colspan="2"><center>
<input
type="button" value="Submit" name="submit"
onclick="return
chkForm();" ondblclick="return cal();"/>
<input type="button"
value="Reset"></center> </td>
</tr>
</form>
</table>
</body>
</html>