473,703 Members | 2,970 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stop a redirect if not validated

KL
I am trying to get a form to work with validating a checkbox. It
validates the checkbox ok, but it always redirects, even if the box
isn't checked...it does alert, but I was hoping that it would stay on
the current page and not redirect unless the box IS checked. I really
can't see what I did wrong. Any and all help would be appreciated.

My code so far is:

<HTML>
<HEAD>
<TITLE>Applicat ion</TITLE>
<script type="text/javascript">

function validate()
{

var test=document.g etElementById(" CCAcknowledgeme nt").checked
submitOK="true"
if (test==false)
{
alert ("To process your information, you must acknowledge that your
credit report will be verified and

analyzed. Please check the appropriate box.")

}

{
window.navigate ('index3.html') ;
}

</script>
</HEAD>
<BODY bgcolor="#3867A D"
onLoad="self.fo cus();document. Miniapp.FirstNa me.focus()">
<CENTER>
TEST OF APPLICATION LINK
</CENTER>
<CENTER><TABL E BORDER="0" WIDTH="500"><TD >
<FORM METHOD="POST" ACTION="gdform. asp" name="Miniapp"
ONSUBMIT="valid ate();">
<input type="hidden" name="subject" value="Applicat ion Submission" />
<input type="hidden" name="redirect" value="index3.h tml" />

<p</p>
<FIELDSET>
<LEGEND><b>St ep Three: Credit Check Acknowledgement </b></LEGEND>
<p><INPUT TYPE="checkbox" id="CCAcknowled gement"
onclick="Toggle Check()"

name="CCAcknowl edgement"><font size="5">Testin g of
Acknowledgement .</font></p>
</FIELDSET>
</TD></TABLE>

</CENTER>
<center><inpu t type="submit" value="Submit" /<INPUT
TYPE="reset"></center>
</form>
</BODY>
</HTML>

Jul 21 '06 #1
3 3389
KL said the following on 7/20/2006 10:31 PM:
I am trying to get a form to work with validating a checkbox. It
validates the checkbox ok, but it always redirects, even if the box
isn't checked...it does alert, but I was hoping that it would stay on
the current page and not redirect unless the box IS checked. I really
can't see what I did wrong. Any and all help would be appreciated.
You left out the word "else".
My code so far is:

<HTML>
<HEAD>
<TITLE>Applicat ion</TITLE>
<script type="text/javascript">

function validate()
{

var test=document.g etElementById(" CCAcknowledgeme nt").checked
submitOK="true"
What is submitOK used for? And, if you are using it as a Boolean, it
should be submitOK = true, without the parentheses.
if (test==false)
if (!test)

test it.
{
alert ("To process your information, you must acknowledge that your
credit report will be verified and

analyzed. Please check the appropriate box.")

}
Here is where the word "else" is missing.
{
window.navigate ('index3.html') ;
window.navigate shouldn't be used. Set the location property.
}
Here, there is a closing } missing.

It is totally surprising that you get an alert from that code.

Have the function return test. If it is true, then the form gets
submitted. If it is false, the form won't get submitted.

And what is with all the HTML3.2 code?

There is more that could be said about it, but that is enough to get you
started.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 21 '06 #2
KL
Randy Webb wrote:
KL said the following on 7/20/2006 10:31 PM:
I am trying to get a form to work with validating a checkbox. It
validates the checkbox ok, but it always redirects, even if the box
isn't checked...it does alert, but I was hoping that it would stay on
the current page and not redirect unless the box IS checked. I really
can't see what I did wrong. Any and all help would be appreciated.

You left out the word "else".
I added the else...
>
My code so far is:

<HTML>
<HEAD>
<TITLE>Applicat ion</TITLE>
<script type="text/javascript">

function validate()
{

var test=document.g etElementById(" CCAcknowledgeme nt").checked
submitOK="true"

What is submitOK used for? And, if you are using it as a Boolean, it
should be submitOK = true, without the parentheses.
My bad...I took it out, but forgot that one spot
>
if (test==false)

if (!test)

test it.
got that now
>
{
alert ("To process your information, you must acknowledge that your
credit report will be verified and

analyzed. Please check the appropriate box.")

}

Here is where the word "else" is missing.
{
window.navigate ('index3.html') ;

window.navigate shouldn't be used. Set the location property.
I do not understand what you mean here. I am new to Javascript.
>
}

Here, there is a closing } missing.

It is totally surprising that you get an alert from that code.

Have the function return test. If it is true, then the form gets
submitted. If it is false, the form won't get submitted.

And what is with all the HTML3.2 code?
Heh, I haven't had the time yet to learn 4.0 ... and I am self taught
for 3.2
>
There is more that could be said about it, but that is enough to get you
started.
Don't be shy! I really do want to know where I am going wrong...I
won't learn if my mistakes aren't pointed out to me! And I appreciate
your time and efforts to help me!
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 21 '06 #3
KL said the following on 7/21/2006 12:38 AM:
Randy Webb wrote:
>KL said the following on 7/20/2006 10:31 PM:
>>I am trying to get a form to work with validating a checkbox. It
validates the checkbox ok, but it always redirects, even if the box
isn't checked...it does alert, but I was hoping that it would stay on
the current page and not redirect unless the box IS checked. I really
can't see what I did wrong. Any and all help would be appreciated.
You left out the word "else".

I added the else...
>>My code so far is:

<HTML>
<HEAD>
<TITLE>Applic ation</TITLE>
<script type="text/javascript">

function validate()
{

var test=document.g etElementById(" CCAcknowledgeme nt").checked
submitOK="tru e"
What is submitOK used for? And, if you are using it as a Boolean, it
should be submitOK = true, without the parentheses.

My bad...I took it out, but forgot that one spot
Actually, I used the wrong word. Not parentheses, but quotation marks.
>>if (test==false)
if (!test)

test it.

got that now
>>{
alert ("To process your information, you must acknowledge that your
credit report will be verified and

analyzed. Please check the appropriate box.")

}
Here is where the word "else" is missing.
>> {
window.naviga te('index3.html ');
window.navigat e shouldn't be used. Set the location property.

I do not understand what you mean here. I am new to Javascript.
Well, actually, you shouldn't be using either for what you are doing.
Have the function validate the form. If it should be submitted, return
true. Otherwise, return false. Then, the form gets submitted or they
stay where they are.

But, to answer you, you set the location property:

document.locati on = "someWhere.html ";

or:

window.location = "someWhere.html ";

Which you use depends on what navigation you want to take place. In a
non-frameset, they do the same thing. In a frameset they don't do the
same thing.
>> }
Here, there is a closing } missing.

It is totally surprising that you get an alert from that code.

Have the function return test. If it is true, then the form gets
submitted. If it is false, the form won't get submitted.

And what is with all the HTML3.2 code?

Heh, I haven't had the time yet to learn 4.0 ... and I am self taught
for 3.2
Forget HTML3.2, learn HTML4.01 (at a minimum) with CSS. It will make
your life a lot simpler.

For questions about them:

HTML: comp.infosystem s.www.authoring.html
CSS: comp.infosystem s.www.authoring.stylesheets
>There is more that could be said about it, but that is enough to get you
started.

Don't be shy! I really do want to know where I am going wrong...I
won't learn if my mistakes aren't pointed out to me! And I appreciate
your time and efforts to help me!
One thing I don't think I could ever be accused of is being shy.

Fix the errors already shown, then post back with a URL to a sample
page. The critiques around here are endless.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 21 '06 #4

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

Similar topics

4
9973
by: TG | last post by:
I have a validation form that must behave differently based on the results of a PHP validation check. I have a post command at the top of my form that calls itself. I don't leave the form when performing the validation check on the values that were entered into the form, I simply repost the form to perform the PHP validation. If any of the values that have been entered into the form are incorrect, I display a warning message on the screen...
1
2588
by: ssss ggggg | last post by:
I have response.redirect("/home.asp") in my code but instead of redirecting to that page it sometimes redirects to the current page ("register.asp"). Its temperamental. Has this happened to anyone else? If so, please help. I am about to pull my hair out. one last thing -- I don't believe any content has been already written to the client because I don't receive an error message. I heard that a proxy server (which I have) might prevent...
2
1761
by: CSharpguy | last post by:
I created a log in screen going against my database. I can validate the users fine, and if the user is validating but I can't redirect the users to the next page. I'm getting this error message: {Text = Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.} what does this mean and how can I take the user once they're validated to the next page?
2
1500
by: John | last post by:
On my web app I require a user to log in so I can validate them. At times I'll be sending emails out for a reporting page in the web app, How can I have the user goto the link I sent to them after they log in and get validated? example: I send http://www.mycaresales.com/reports.aspx now when they click that link it will take them to the logon page, they get validated login then they see the first page of my web app, once they log in I...
3
3058
by: Mark Huebner | last post by:
I have an aspx web page with the following C# code in the page load event. Can somebody tell me if the Response.Redirect() will cause my tLoadDNN thread to stop executing before it is finished? tLoadDNN might occasionally take up to 16 seconds to complete. protected void Page_Load(object sender, EventArgs e) { Thread tLoadDNN = new Thread(new ThreadStart(LoadDNN)); tLoadDNN.Start(); Response.Redirect("Default1.htm");
5
4569
by: venner | last post by:
I'm having an issue with an ASP.NET website after upgrading to ASP.NET 2.0. The website makes use of a central authentication service (CAS) provided at the university I work for. Each page checks a session variable, and if it is not present, does a Response.Redirect to a webpage for the CAS passing a url parameter for the url to post back to. The CAS provides a page for the user to log into, validates the username and password, and then...
8
4612
by: photoboy | last post by:
I have racked by brain long enough on this, so now I need the help of someone who knows what they are doing. Here is what I am trying to achieve: First, I have two radio buttons (both unchecked) that need to be validated when the submit button is clicked. Instead of the standard alert window popping up (which I have now), I want the radio button background color to change from the table color (E2E2E2) to red (FF0000) for both buttons...
13
2023
by: Adhal | last post by:
Hi, How can I stop hotlinking to a specific file, and I want it to redirect it to a PHP link so I can monitor the number of downloads. Here is my site with the download page: http://www.adhal.org/software/downloads.htm And here is softpedia directly connecting to my file and bypassing the counter php. http://www.softpedia.com/get/File-managers/HashNET.shtml
2
4003
by: Norm | last post by:
The error that pops up in a JS alert box is: Sys.WebForms.PageRequestManagerParserErrorException: The message from the server could not be parsed. ... "<DOCTYPE ..." I have three update panels and a couple of AJAX toolkit extenders on the page. The button that causes the problem is simply sending an email then redirecting to a "Thank You" page. There are two update panels that are both set to conditionally trigger on that button...
0
8744
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9240
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9103
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8952
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6585
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4417
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2426
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2055
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.