|
 |
asp_web_howto thread: form validation
Message #1 by REdwards@c... on Fri, 28 Jun 2002 20:02:23
|
|
This is not working for me. It submits fine but it does not bring up the
alert when the the TimeSpent field is empty and OpenClosed has a value
of "Closed":
<script language=vbscript>
sub B1_OnClick()
If recUpdate.OpenClosed.value="Closed" AND recUpdate.TimeSpent.value=""
then Alert "You must enter the Time Spent to close this record"
Exit Sub
End If
Call recUpdate.submit()
End Sub
</script>
I have it at the end of my form. The form name is recUpdate and the submit
button name is B1.
Message #2 by Greg Griffiths <greg.griffiths@g...> on Fri, 28 Jun 2002 22:35:54 +0100
|
|
most of us tend to write client side code in Javascript as it is more
browser independant, try :
<script language="javascript">
function validate_form()
{
if ((recUpdate.OpenClosed.value=='Closed') &&
(recUpdate.TimeSpent.value.length==0))
{
alert("You must enter the Time Spent to close this record");
}
}
</script>
I don't think that VBScript has a funciton called ALERT.
At 20:02 28/06/02 +0000, you wrote:
>This is not working for me. It submits fine but it does not bring up the
>alert when the the TimeSpent field is empty and OpenClosed has a value
>of "Closed":
>
><script language=vbscript>
>
>sub B1_OnClick()
>
>If recUpdate.OpenClosed.value="Closed" AND recUpdate.TimeSpent.value=""
> then Alert "You must enter the Time Spent to close this record"
>
>Exit Sub
>End If
>
>Call recUpdate.submit()
>End Sub
>
></script>
>
>I have it at the end of my form. The form name is recUpdate and the submit
>button name is B1.
>
>---
>
>Improve your web design skills with these new books from Glasshaus.
>
>Usable Web Menus
>http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
>r-20
>Constructing Accessible Web Sites
>http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
>r-20
>Practical JavaScript for the Usable Web
>http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
>r-20
Message #3 by REdwards@c... on Sat, 29 Jun 2002 00:18:16
|
|
I got it to work fine with vb script. Everything was alright except that
the "Alert" needed to be on it's own line.
VB script has an Alert.
|
|
 |