Squall Leonhart
11-21-2003, 12:41 AM
Hi, Guys.
I have question about date/time validation.
Please take a look at following code.
code:--------------------------------------------------------------------------------
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript1.2" SRC="HM_Loader.js" TYPE='text/javascript'></SCRIPT>
<script language="JavaScript" type="text/javascript">
function checkthis()
{
if (document.frmAdd.description.value=="")
{
alert ('Please fill out textbox')
return false;
} else
{
if(confirm("Are you sure you want to add this?"))
{
return true;
}
else
{
return false;
}
}
}
</script>
</HEAD>
<BODY LEFTMARGIN=0 MARGINWIDTH="0" MARGINHEIGHT="0">
<%
Dim adoCon 'Holds the Database Connection Object
Dim rsEdit 'Holds the recordset for the new record to be added to the database
Dim strSQL 'Holds the SQL query for the database
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("tech_re.mdb")
Set rsEdit = Server.CreateObject("ADODB.Recordset")
%>
<form name="frmAdd" method="post" action="updateRequest.asp?state=add" onsubmit="return checkthis();">
<table border="0" cellpadding="3" cellspacing="1" width="100%" class="forumline">
<tr>
<th class="thHead" colspan="2" height="25"><b>Add the new item</b></th>
</tr>
<tr>
<td class="row1" width="22%"><span class="gen"><b>Description</b></span></td>
<td class="row2" width="78%"><span class="gen"><input type="text" name="description" style="width:450px" maxlength="50"></span></td>
</tr>
<tr>
<td class="row1" width="22%"><span class="gen"><b>Date :</b></span></td>
<td class="row2" width="78%"><span class="gen"><%todaysDate=now()%><input type="text" name="Date" style="width:450px" maxlength="21" value="<%=FormatDateTime(todaysDate,0)%>"></span></td>
</tr>
<tr>
<td class="row1" width="22%"><span class="gen"><b>Status :</b></span></td>
<td class="row2" width="78%"> <span class="gen"><input type="checkbox" name="status"></span></td>
</tr>
<tr>
<td class="catBottom" colspan="2" align="center" height="28"><input type="submit" name="Submit" value="Submit"> <button onClick="history.go(-1)" style="width:60px;">Go back</button></td>
</tr>
</table>
</form>
<%
'Reset server objects
rsEdit.Close
Set rsEdit = Nothing
Set adoCon = Nothing
%>
</BODY>
</HTML>
--------------------------------------------------------------------------------
As you can see there is textbox named 'Date' on this page.
When this page appears, value <%=FormatDateTime(todaysDate,0)%> is inside textbox.
Problem is when user enters the time not as same format as one that appeared at first place.
How can I alert user "You haven't entered right format of date"?
Thanks. Please help me.
I have question about date/time validation.
Please take a look at following code.
code:--------------------------------------------------------------------------------
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript1.2" SRC="HM_Loader.js" TYPE='text/javascript'></SCRIPT>
<script language="JavaScript" type="text/javascript">
function checkthis()
{
if (document.frmAdd.description.value=="")
{
alert ('Please fill out textbox')
return false;
} else
{
if(confirm("Are you sure you want to add this?"))
{
return true;
}
else
{
return false;
}
}
}
</script>
</HEAD>
<BODY LEFTMARGIN=0 MARGINWIDTH="0" MARGINHEIGHT="0">
<%
Dim adoCon 'Holds the Database Connection Object
Dim rsEdit 'Holds the recordset for the new record to be added to the database
Dim strSQL 'Holds the SQL query for the database
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("tech_re.mdb")
Set rsEdit = Server.CreateObject("ADODB.Recordset")
%>
<form name="frmAdd" method="post" action="updateRequest.asp?state=add" onsubmit="return checkthis();">
<table border="0" cellpadding="3" cellspacing="1" width="100%" class="forumline">
<tr>
<th class="thHead" colspan="2" height="25"><b>Add the new item</b></th>
</tr>
<tr>
<td class="row1" width="22%"><span class="gen"><b>Description</b></span></td>
<td class="row2" width="78%"><span class="gen"><input type="text" name="description" style="width:450px" maxlength="50"></span></td>
</tr>
<tr>
<td class="row1" width="22%"><span class="gen"><b>Date :</b></span></td>
<td class="row2" width="78%"><span class="gen"><%todaysDate=now()%><input type="text" name="Date" style="width:450px" maxlength="21" value="<%=FormatDateTime(todaysDate,0)%>"></span></td>
</tr>
<tr>
<td class="row1" width="22%"><span class="gen"><b>Status :</b></span></td>
<td class="row2" width="78%"> <span class="gen"><input type="checkbox" name="status"></span></td>
</tr>
<tr>
<td class="catBottom" colspan="2" align="center" height="28"><input type="submit" name="Submit" value="Submit"> <button onClick="history.go(-1)" style="width:60px;">Go back</button></td>
</tr>
</table>
</form>
<%
'Reset server objects
rsEdit.Close
Set rsEdit = Nothing
Set adoCon = Nothing
%>
</BODY>
</HTML>
--------------------------------------------------------------------------------
As you can see there is textbox named 'Date' on this page.
When this page appears, value <%=FormatDateTime(todaysDate,0)%> is inside textbox.
Problem is when user enters the time not as same format as one that appeared at first place.
How can I alert user "You haven't entered right format of date"?
Thanks. Please help me.