arravalli12
Programmer
I have a form and am updating only one text box value. I have a server side validation which will display error message and new value is displayed on text box when you hit update button and if there is any error.
Else it will update the record.
Now when error message appears, user wants to reset the value to original. Since I am giving server side validation error message, the reset button does not change to original values.
Is there any way, I can do that. Any help will be appreciated. I do not want to use client side validation..
Thanks
My code is:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include virtual="/Connections/DataCom_Server.asp" -->
<!--#include virtual="/common/HeaderDisplay.asp"-->
<!-- #include virtual="/common/PLCBsignin.asp" -->
<!-- #include virtual="/Common/SecurityCheck.asp" -->
<script language="JavaScript">
function setFocus()
{
FamilyCode2_update.FamilyCode.focus();
FamilyCode2_update.FamilyCode.select()
}
</script>
<script>
history.forward();
</script>
<%
dim CD_NO
CD_NO = request.querystring("code_no")
dim MM_abortEdit
MM_abortEdit = false
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_DataCom_Server_STRING
Recordset1.Source = "select CDE_NO,FAMILY_CDE from SYSUSR.FAMILY_CDE_REC where CDE_NO = " & CD_NO
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
If Request.form("Submit") <> "" Then
Dim CDE_NO,FAMILY_CDE
CDE_NO = Request.form("code_no")
FAMILY_CDE = Request.Form("FamilyCode")
FAMILY_CDE = trim(FAMILY_CDE)
if isnumeric(FAMILY_CDE) then %>
<% if instr(FAMILY_CDE,",")>0 OR instr(FAMILY_CDE,".")>0 or instr(FAMILY_CDE,"+")>0 or instr(FAMILY_CDE,"-")>0 then
MM_abortEdit= true
response.write "<font color=red><br>Error on Code Number-" & CDE_NO&". You entered- "&FAMILY_CDE&".(Please enter numbers between 10 and 989. This record is not updated)</font>"
%>
<% Elseif (FAMILY_CDE>=1 and FAMILY_CDE < 10) or FAMILY_CDE > 989 then
MM_abortEdit= true
response.write "<font color=red><br>Error on Code Number-" & CDE_NO&". You entered- "&FAMILY_CDE&".(Please enter numbers between 10 and 989. This record is not updated)</font>"
end if
else
MM_abortEdit= true
response.write "<font color=red><br>Error on Code Number-" & CDE_NO&". You entered-"&FAMILY_CDE&".(Please enter numbers. This record is not updated)</font>"
end if
'select case len(FAMILY_CDE)
'case "3"
'FAMILY_CDE = "0" & FAMILY_CDE
'case "2"
'FAMILY_CDE = "00" & FAMILY_CDE
'end select
' If (FAMILY_CDE Mod 10) = 0 Then
'response.write "<font color=red><br>Error on Code Number-" &CDE_NO&". You entered-"&FAMILY_CDE&".(Please enter numbers which should not end in zero. This record is not updated)</font>"
'MM_abortEdit = True
'end if
If (MM_abortEdit = false) Then
set Doupdate = Server.CreateObject("ADODB.Command")
Doupdate.ActiveConnection = MM_DataCom_Server_STRING
Doupdate.CommandText = "Update SYSUSR.FAMILY_CDE_REC Set FAMILY_CDE ="& FAMILY_CDE & ", CHNG_FLG = 'Y' WHERE CDE_NO= "&CDE_NO
'response.write Doupdate.CommandText
'response.write Doupdate1.CommandText
'response.end
Doupdate.CommandType = 1
Doupdate.CommandTimeout = 0
Doupdate.Prepared = true
Doupdate.Execute()
response.write " Record updated"
'Response.Redirect("familycode_Update.asp")
end if
end if
%>
<html>
<link rel="stylesheet" type="text/css" href="common/gen-Style2.css">
<style type="text/css">
<!--
.style1 {
color: #663300;
font-weight: bold;
}
-->
</style>
<body onload="setFocus();if(history.length>=0)history.go(+1)">
<%
if MM_abortEdit= true then
FAMILY_CDE = Request.Form("FamilyCode")
else
FAMILY_CDE = trim((Recordset1.Fields.Item("FAMILY_CDE").Value))
end if%>
<form ACTION="" METHOD="Post" name="FamilyCode2_update">
<p align="center"><span style="font-size: 10px"><a href=" PLCB Industry Partners Main Page</a></span></p>
<p align="center"><span style="font-size: 10px">
<a href="familycode_Update.asp"> Family Code:Individual Updates</a></span></p>
<table width="42%" border="1" cellpadding="5" cellspacing="0" align="center" bordercolor="#C8C8D2">
<tr bgcolor="#FFFDE1" class="table-categories">
<td width="50%" align="center"><span class="style1"><font face=Verdana size=1>Code Number</font></span></td>
<td width="50%"><span class="style1"><font face=Verdana size=1>Family Code</font></span></td>
</tr>
<tr bgcolor="#f0f0f0" class="table-data">
<% 'box1 = (Recordset1.Fields.Item("code_no").Value) %>
<td align="center"> <span class="newsLink newsLink"><%=(Recordset1.Fields.Item("CDE_NO").Value)%>
<input name="code_no" type = hidden value="<%=(Recordset1.Fields.Item("CDE_NO").Value)%>">
</span></td>
<td><input name="FamilyCode" type="text" value="<%=FAMILY_CDE%>" maxlength="3"></td>
</tr>
</table>
<div align="center">
<input name="submit" type="submit" value="Update" >
<input name="Reset" type="reset" value="Reset" >
</div>
</form>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
Else it will update the record.
Now when error message appears, user wants to reset the value to original. Since I am giving server side validation error message, the reset button does not change to original values.
Is there any way, I can do that. Any help will be appreciated. I do not want to use client side validation..
Thanks
My code is:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include virtual="/Connections/DataCom_Server.asp" -->
<!--#include virtual="/common/HeaderDisplay.asp"-->
<!-- #include virtual="/common/PLCBsignin.asp" -->
<!-- #include virtual="/Common/SecurityCheck.asp" -->
<script language="JavaScript">
function setFocus()
{
FamilyCode2_update.FamilyCode.focus();
FamilyCode2_update.FamilyCode.select()
}
</script>
<script>
history.forward();
</script>
<%
dim CD_NO
CD_NO = request.querystring("code_no")
dim MM_abortEdit
MM_abortEdit = false
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_DataCom_Server_STRING
Recordset1.Source = "select CDE_NO,FAMILY_CDE from SYSUSR.FAMILY_CDE_REC where CDE_NO = " & CD_NO
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
If Request.form("Submit") <> "" Then
Dim CDE_NO,FAMILY_CDE
CDE_NO = Request.form("code_no")
FAMILY_CDE = Request.Form("FamilyCode")
FAMILY_CDE = trim(FAMILY_CDE)
if isnumeric(FAMILY_CDE) then %>
<% if instr(FAMILY_CDE,",")>0 OR instr(FAMILY_CDE,".")>0 or instr(FAMILY_CDE,"+")>0 or instr(FAMILY_CDE,"-")>0 then
MM_abortEdit= true
response.write "<font color=red><br>Error on Code Number-" & CDE_NO&". You entered- "&FAMILY_CDE&".(Please enter numbers between 10 and 989. This record is not updated)</font>"
%>
<% Elseif (FAMILY_CDE>=1 and FAMILY_CDE < 10) or FAMILY_CDE > 989 then
MM_abortEdit= true
response.write "<font color=red><br>Error on Code Number-" & CDE_NO&". You entered- "&FAMILY_CDE&".(Please enter numbers between 10 and 989. This record is not updated)</font>"
end if
else
MM_abortEdit= true
response.write "<font color=red><br>Error on Code Number-" & CDE_NO&". You entered-"&FAMILY_CDE&".(Please enter numbers. This record is not updated)</font>"
end if
'select case len(FAMILY_CDE)
'case "3"
'FAMILY_CDE = "0" & FAMILY_CDE
'case "2"
'FAMILY_CDE = "00" & FAMILY_CDE
'end select
' If (FAMILY_CDE Mod 10) = 0 Then
'response.write "<font color=red><br>Error on Code Number-" &CDE_NO&". You entered-"&FAMILY_CDE&".(Please enter numbers which should not end in zero. This record is not updated)</font>"
'MM_abortEdit = True
'end if
If (MM_abortEdit = false) Then
set Doupdate = Server.CreateObject("ADODB.Command")
Doupdate.ActiveConnection = MM_DataCom_Server_STRING
Doupdate.CommandText = "Update SYSUSR.FAMILY_CDE_REC Set FAMILY_CDE ="& FAMILY_CDE & ", CHNG_FLG = 'Y' WHERE CDE_NO= "&CDE_NO
'response.write Doupdate.CommandText
'response.write Doupdate1.CommandText
'response.end
Doupdate.CommandType = 1
Doupdate.CommandTimeout = 0
Doupdate.Prepared = true
Doupdate.Execute()
response.write " Record updated"
'Response.Redirect("familycode_Update.asp")
end if
end if
%>
<html>
<link rel="stylesheet" type="text/css" href="common/gen-Style2.css">
<style type="text/css">
<!--
.style1 {
color: #663300;
font-weight: bold;
}
-->
</style>
<body onload="setFocus();if(history.length>=0)history.go(+1)">
<%
if MM_abortEdit= true then
FAMILY_CDE = Request.Form("FamilyCode")
else
FAMILY_CDE = trim((Recordset1.Fields.Item("FAMILY_CDE").Value))
end if%>
<form ACTION="" METHOD="Post" name="FamilyCode2_update">
<p align="center"><span style="font-size: 10px"><a href=" PLCB Industry Partners Main Page</a></span></p>
<p align="center"><span style="font-size: 10px">
<a href="familycode_Update.asp"> Family Code:Individual Updates</a></span></p>
<table width="42%" border="1" cellpadding="5" cellspacing="0" align="center" bordercolor="#C8C8D2">
<tr bgcolor="#FFFDE1" class="table-categories">
<td width="50%" align="center"><span class="style1"><font face=Verdana size=1>Code Number</font></span></td>
<td width="50%"><span class="style1"><font face=Verdana size=1>Family Code</font></span></td>
</tr>
<tr bgcolor="#f0f0f0" class="table-data">
<% 'box1 = (Recordset1.Fields.Item("code_no").Value) %>
<td align="center"> <span class="newsLink newsLink"><%=(Recordset1.Fields.Item("CDE_NO").Value)%>
<input name="code_no" type = hidden value="<%=(Recordset1.Fields.Item("CDE_NO").Value)%>">
</span></td>
<td><input name="FamilyCode" type="text" value="<%=FAMILY_CDE%>" maxlength="3"></td>
</tr>
</table>
<div align="center">
<input name="submit" type="submit" value="Update" >
<input name="Reset" type="reset" value="Reset" >
</div>
</form>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>