473,394 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Need help with conditional creation of a popup window

Hi,

I'm writing a CGI application and here's what I'm stuck with. There
are some text boxes in an html form that I want to validate. The
validation needs to happen on the server side because the data to
validate against is inside a mysql database residing on the server. I
want to present the user with a popup only if the validation fails.
Ideally the user doesn't even know the validation is happening unless
it fails. He just moves from field to field. I know how to trap the
condition of the user moving out of a text field. I know how to invoke
a CGI script from javascript. What I don't know is how, if it's even
possible, to have the result of moving out of the text field trigger
code that either returns silently or opens a popup, depending on what
I find in my validation code.

Is this possible in Javascript? If not can someone recommend what
language I might be able to do this in?

Thanks,
SL
Jul 23 '05 #1
3 1861
What you're wanting to do is probably more trouble than it's worth, since
the only way to cause anything to happen in a web environment is to submit a
page to some process somewhere. As an end user, I would say that it's
better to validate everything at once at the end, rather than interupting me
after every field where I make a mistake. As a programmer, I'd tell you
it's better to validate on the server since the end user can turn off
javascript.

Now, if you have control of your environment, as in an intranet application,
you can put an IFRAME on your page and submit your validations to that.
Communicate with the IFRAME by its id, and it communicates back by referring
to its parent.

Still better to validate on the server, though.

- Wm

--
William Morris
Product Development, Seritas LLC
Kansas City, Missouri

"Sol Linderstein" <sl**********@yahoo.com> wrote in message
news:e4**************************@posting.google.c om...
Hi,

I'm writing a CGI application and here's what I'm stuck with. There
are some text boxes in an html form that I want to validate. The
validation needs to happen on the server side because the data to
validate against is inside a mysql database residing on the server. I
want to present the user with a popup only if the validation fails.
Ideally the user doesn't even know the validation is happening unless
it fails. He just moves from field to field. I know how to trap the
condition of the user moving out of a text field. I know how to invoke
a CGI script from javascript. What I don't know is how, if it's even
possible, to have the result of moving out of the text field trigger
code that either returns silently or opens a popup, depending on what
I find in my validation code.

Is this possible in Javascript? If not can someone recommend what
language I might be able to do this in?

Thanks,
SL

Jul 23 '05 #2
William Morris wrote:
<snip>
As a programmer, I'd tell you it's better to validate on
the server since the end user can turn off javascript.

<snip>

You make it sound like it is an either-or situation. Validating on the
server is essential because, as you say, the user can turn javascript
off. They can also subvert the javascript so it will allow any
submission at all, fake the form on a different page or fake the request
using non-browser software.

But that doesn't render client-side validation invalid as an additional
layer. For users who are not messing around and have javascript enabled,
if client side code can tell that a the server-side validation will
reject the form date then it doesn't seem unreasonable to let the user
know at that point and to not send the data to the server. It will
eliminate unnecessary requests to the server and save the user waiting
for a response that will just tell them that they need to correct the
form.

On the other hand, client-side validation that is done by making
background requests to the server doesn't seem to offer any advantages
over exclusively server-side validation, and it certainly introduces
considerable complexity and reliability issues.

Richard.
Jul 23 '05 #3
In article <e4**************************@posting.google.com >,
sl**********@yahoo.com enlightened us with...
Hi,

I'm writing a CGI application and here's what I'm stuck with. There
are some text boxes in an html form that I want to validate. The
validation needs to happen on the server side because the data to
validate against is inside a mysql database residing on the server. I
want to present the user with a popup only if the validation fails.
Ideally the user doesn't even know the validation is happening unless
it fails. He just moves from field to field. I know how to trap the
condition of the user moving out of a text field. I know how to invoke
a CGI script from javascript. What I don't know is how, if it's even
possible, to have the result of moving out of the text field trigger
code that either returns silently or opens a popup, depending on what
I find in my validation code.

Is this possible in Javascript? If not can someone recommend what
language I might be able to do this in?

Thanks,
SL


Tested in NN7. Should work in IE5+, too.
Modify it to suit. I'm not a big perl geek, so this is a really simple
test. ;)
Watch for word-wrap.

test.htm
----------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title> Test server-side JS </title>
</head>

<body>
<script type="text/javascript">
function checkIt(variable, value)
{
var newScript = "cgi-bin/validateJS.cgi?"+variable+"="+value;

var body = document.getElementsByTagName('body').item(0)
var scriptTag = document.getElementById('loadScript');
if(scriptTag) body.removeChild(scriptTag);
script = document.createElement('script');
script.src = newScript;
script.type = 'text/javascript';
script.id = 'loadScript';
body.appendChild(script)
}
</script>
<p>Test.</p>
<form id="f1" action="">
<input type="text" name="t1" id="t1" onChange="checkIt(this.name,
this.value)">
</body>
</html>
validateJS.cgi (perl)
-------
#!/opt/x11r6/bin/perl
use CGI qw(:all);

my @valArray = split(/=/,$ENV{QUERY_STRING});

print "Content-type: text/javascript\n\n";

# myPass is the password
$myPass = "foobar";

if ("$valArray[1]" eq "$myPass")
{
print "alert(\"Success!!\")";
}
else
{
print "alert(\"Failure!!\")";
}

# end file

HTH
--
--
~kaeli~
No one is listening until you make a mistake.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
3
by: Steve | last post by:
Hi, I have a nice little script that works well displaying images on my website. It's a script where if you clik a thumbnail image a pop up window opens that contains a larger version of the same...
16
by: St. Rechsteiner | last post by:
Hi How i made the same effect in xHTML like the - target="_blank" - Tag in HTML 4.01? I will use it with xHTML and CSS ... but the validator say's to me, that this tag wasn't valid for xHTML!...
2
by: Mike Button | last post by:
Hello all, I am really really desperate on what I should do, and I am asking for help from anyone in this newsgroup, here's the situation: I am creating a form that is being run on a server...
1
by: David Cho | last post by:
I am trying to use the server side code to have a popup window come up only under a certain condition. For example, the user presses a button to retrieve a set of records. So - If there are...
3
by: Chris | last post by:
Hi, I have a parent page that loads a popup and when the OK button is press it pass the value back to the parent form textbox. It passes the value but it doesn't close the popup but also open...
5
by: Chris | last post by:
Hi, I have been trying for days, yes days, to use the calender from the asp.net timetracker starter kit. I am now frustrated. I finally get the popup calender to popup but when I click ok to...
11
by: Alex.Svetos | last post by:
Hello, I'm trying to get a popup to keep focus when it is re-clicked. The script below is supposed to produce this exact behaviour, however it doesn't work, at least on firefox 1.0.7 and moz...
1
by: lawsongs | last post by:
Hi: I have a one-page salesletter website and an accompanying order page. I want a popup to appear only if the visitor leaves both pages. In other words, I’m trying to have the popup appear only...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.