Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Popup Window

Status
Not open for further replies.

slr22

MIS
Jun 26, 2002
80
US
I have an asp page that runs server side. I need to be able to have a pop up window on the client side. What I want is when a user inputs an invalid entry, it pop up a screen telling them what a correct entry would be. The window.open does not work for me because it is client side. Does anyone know how to do this?

Thanks,
Sandy
 
If your doing your form validation inside <script> tags then you can just use the msgbox command.
i.e.
msgbox &quot;your text here&quot;
msgbox txtSomeHTMLtxtBox

You can always tie this into a _onClick or _onChange event for your input boxes too.
i.e. if the input box is name=&quot;test&quot; then name your sub &quot;test_onChange&quot; and it will fire your validation when they change the value.
 
depending on how much validation there is, you might also consider using the javascript onSubmit. that way the whole form is check at the time it's submitted and will automatically popup the message box client side.
hth

&quot;Where's the Ka-Boom? There's supposed to be an Earth-shattering Ka-Boom!&quot;
Marvin the Martian
 
From my understanding, the msgbox is for client side. I have to use server side. When I tried to use the msgbox it gave me an error saying permission denied. Here is the code that I used:

<SCRIPT ID=serverEventHandlersVBS LANGUAGE=vbscript runat=server>

Sub btnSubmit_onclick()
if txtProjDate.value <> &quot;&quot; and IsDate(txtProjDate.value) = false then
errmsg = &quot;Project Start Date is a date field. Please enter the date in the format mm/dd/yyyy&quot;
else
OktoProcess = true
end if

if (OktoProcess=false) then
msgbox(&quot;Error Message&quot;)
else
Response.Redirect(&quot;MainMenu.asp&quot;)
end if
End Sub

This is the error message I get:

Microsoft VBScript runtime error '800a0046'

Permission denied: 'msgbox'

Is there something that I did wrong or is there something that I need to change to get this to work?



 
You can use a mixture of scripts in your web page that run both on the server and on the client simultaneously. Of course, you'll need separate <script></script> element pairs for the server-side scripts and for the scripts you want to have run on the client's computer. I'm sure the little code below is far from what you'll actually need, but maybe it will help. :)

<head>
<title>
Snazzy Title
</title>
</head>
<body>
<form name=&quot;frmTest&quot;>

<input name=&quot;txtSomeData&quot; type=&quot;text&quot; size=6 />
<input name=&quot;cmdSubmit&quot; type=&quot;submit&quot; value=&quot;Submit&quot; />

<!-- Omittion of the RUNAT=&quot;server&quot; attribute below
causes the script to be ran on the client (which
is what we want: we want to validate something on
the page before it is sent off to the server.) -->

<script language=&quot;VBScript&quot;>
<!--

Sub cmdSubmit_onClick()
x = document.frmTest.txtSomeData.value
If Not(IsNumeric(x)) Then
MsgBox &quot;Please enter numeric characters only.&quot;
Exit Sub
Else
MsgBox &quot;The form has been validated&quot; & _
&quot; and will be sent to the server.&quot;
' Some other code can go here, such as your code to
' submit the form.
End If
End Sub

-->
</script>

<script language=&quot;VBScript&quot; runat=&quot;server&quot;>
<!--
' Whatever code you want or need could go here...
-->
</script>

</form>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top