I am using ASP
In my company, all employees have to sent materials out of premises. Any employee who need to sent material out will use this web application. In the first page, an employee enters firm name, vehicle no, driver name, purpose, persons taking out, received by, remarks. In the second page, employee enters no. of materials to be taken out. In the third page, displays no. of rows for entry of material details like material name, serial_no., qty, weight remarks.
I have written validation for all field. All validation works well. In the third page, validation works well when no. of material taken out is 1. When it is > 1, then no validation works.
Please suggest me, what to do?
I am giving you code for entry and validation.
Thanks and regards,
Vikas
In my company, all employees have to sent materials out of premises. Any employee who need to sent material out will use this web application. In the first page, an employee enters firm name, vehicle no, driver name, purpose, persons taking out, received by, remarks. In the second page, employee enters no. of materials to be taken out. In the third page, displays no. of rows for entry of material details like material name, serial_no., qty, weight remarks.
I have written validation for all field. All validation works well. In the third page, validation works well when no. of material taken out is 1. When it is > 1, then no validation works.
Please suggest me, what to do?
I am giving you code for entry and validation.
Thanks and regards,
Vikas
Code:
<html>
<title>Material Entry Page</title>
<script language="javascript">
function check1(s)
{
var t
var str=s
len=str.length
for(i=0;i<=len;i++)
{
if(str.charAt(i)==0 ||str.charAt(i)==1 ||str.charAt(i)==2 ||str.charAt(i)==3 ||str.charAt(i)==4 ||str.charAt(i)==5 ||str.charAt(i)==6 ||str.charAt(i)==7 ||str.charAt(i)==8 ||str.charAt(i)==9 )
{
continue;
}
else
{
t=2
return t;
}
}
return 0;
}
function check(s)
{
var t
var str=s
len=str.length
if (len==0)
{
t=1
return t;
}
else
{
for(i=0;i<=len;i++)
{
if(str.charAt(i)==0 ||str.charAt(i)==1 ||str.charAt(i)==2 ||str.charAt(i)==3 ||str.charAt(i)==4 ||str.charAt(i)==5 ||str.charAt(i)==6 ||str.charAt(i)==7 ||str.charAt(i)==8 ||str.charAt(i)==9 )
{
t=2
return t;
}
else
{
continue;
}
}
return 0;
}
}
function check2(s)
{
var t
var str=s
len=str.length
if (len==0)
{
t=1
return t;
}
else
{
for(i=0;i<=len;i++)
{
if(str.charAt(i)=="+" ||str.charAt(i)=="-" ||str.charAt(i)=="*"|| str.charAt(i)=="`" ||str.charAt(i)=="!" ||str.charAt(i)=="@" ||str.charAt(i)=="#" ||str.charAt(i)=="$" ||str.charAt(i)=="%" ||str.charAt(i)=="^" ||str.charAt(i)=="&" ||str.charAt(i)=="=" ||str.charAt(i)=="?" ||str.charAt(i)=="<" ||str.charAt(i)==">")
{
t=2
return t;
}
else
{
continue;
}
}
return 0;
}
}
function checkmat()
{
var t,t1;
var str=document.myform.mat.value
t=check2(str);
if(t==2)
{
document.myform.mat.select()
alert("Special characters are not allowed.");
}
if(t==1)
{
document.myform.mat.select()
alert("Material must be entered.");
}
}
function checkcsno()
{
var str=document.myform.csno.value
len=str.length
if (len==0)
{
document.myform.csno.select()
alert("Company serial number must be entered.")
}
}
function checkdsno()
{
var str=document.myform.dsno.value
len=str.length
if (len==0)
{
document.myform.dsno.select()
alert("Department serial number must be entered.")
}
}
function checkqty()
{
var t,t1;
var str=document.myform.qty.value
t=check1(str);
if(t==2)
{
document.myform.qty.select()
alert("Please enter numbers only.")
}
if(str==0)
{
document.myform.qty.select()
alert("Quantity must > 0.")
}
}
function checkrem()
{
var t,t1;
var str=document.myform.rem.value
t=check2(str);
if(t==2)
{
document.myform.rem.select()
alert("Special characters are not allowed.")
}
}
</script>
<%
Set CON = Server.CreateObject("ADODB.Connection")
con.open "Provider=MSDAORA.1;dsn=ops;Password=op;User ID=outpass;Data Source=intradb;Persist Security Info=True"
SET RS=SERVER.CREATEOBJECT("ADODB.RECORDSET")
'RS=CON.EXECUTE("select max(gp_no) from gps")
'gn=rs("max(gp_no)")
gn=session("gno")
%>
<!-- #include file="Hdr.asp" -->
<form name="myform" action="smaterial.asp" METHOD="POST">
<b>Gatepass Number : <font color="blue"><%=GN%></font> <input type="hidden" name="gno" value="<%=GN%>" >
<br><br>
<TABLE border=3 cellPadding=5 cellSpacing=5 width="80%">
<tr>
<TD align='center'><B>SNo.</B></TD>
<TD align='center'><B>Material Name</B></TD>
<TD align='center'><B>Company Serial Number</B></TD>
<TD align='center'><B>Department Serial Number</B></TD>
<TD align='center'><B>Quantity<br>
(Number only)</B></TD>
<TD align='center'><B>Weight<br>
(Number only)</B></TD>
<TD align='center'><B>Remarks</B></TD>
</tr>
<%
k=request.form("mno")
k=cdbl(k)
for i=1 to k
%>
<tr>
<TD ALIGN=CENTER><B><%=i%></TD>
<TD><input type ='text' style="width:250px" name='mat'size=50 onblur="checkmat()"></TD>
<TD><input type ='text' style="width:110px" name='csno'size=10 value='N/A' onblur="checkcsno()"></TD>
<TD><input type ='text' style="width:110px" name='dsno'size=14 value='N/A' onblur="checkdsno()"></TD>
<TD><input type ='text' style="width:60px" name='qty'size=5 value=1 onblur="checkqty()"></TD>
<TD><input type ='text' style="width:60px" name='wt'size=5 value=0></TD>
<TD><input type ='text' style="width:225px" name='rem'size=50 value='N/A' onblur="checkrem()"></TD>
</tr>
<%
next
%>
</table>
<br>
<center><input type="submit" style="width:150px" value="Add"></center>
</form>
</body>
</html>
Comment