473,382 Members | 1,238 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,382 software developers and data experts.

Back with validation through javascript......

Hey.... The validation system that kaeli made works smooth.... Now I was
wondering if it would be correct to make some variations to it like this:
-----original kaeli's code-------

<html>
<head>
<title> test </title>
<script type="text/javascript">
function checkLogin()
{
var a=prompt("enter the password");
if (a=="noway") writeSuccess();
else writeFail();
}
function writeSuccess()
{
document.getElementById("writeArea").innerHTML="Su ccess!";
}
function writeFail()
{
document.getElementById("writeArea").innerHTML="Fa il!";
}
</script>
</head>

<body onLoad="checkLogin()">
<div id="writeArea"></div>
</body>
</html>
-------my variations--------

<html>
<head>
<title> test </title>
<script type="text/javascript">
function checkLogin()
{
myhtml = "thewholelot of my web page from after <body> and until before
</body>
var a=prompt("enter the password");
if (a=="noway") writeSuccess();
else writeFail();
}
function writeSuccess()
{
document.getElementById("writeArea").innerHTML= myhtml;
}
function writeFail()
{
document.getElementById("writeArea").innerHTML="Wr ong password!!! Reload
the page";
}
</script>
</head>

<body onLoad="checkLogin()">
<div id="writeArea"></div>
</body>
</html>
So, you think it's correct? Should I have any kind of consideration since I
am trying to create a character-like variable that is 16kb wide??

Cheers!!!

Yodai
Jul 20 '05 #1
2 1093
In article <Tp***********************@telenews.teleline.es> ,
yo***@spamnot.mail.vu enlightened us with...
Hey.... The validation system that kaeli made works smooth.... Now I was
wondering if it would be correct to make some variations to it like this:

You missed a couple things.

-------my variations--------

<script type="text/javascript">
function checkLogin()
{
myhtml = "thewholelot of my web page from after <body> and until before
</body>
Forgot end quotes. VERY important. Also a semi-colon is standard.
var myhtml = "thewholelot of my web page from after <body> and until
before</body>";

Now, you made this variable that is only good in this function. How is
the other function going to see it?
That's called SCOPE.
Either pass the variable to the other functions or make it global by
putting
var myhtml;
before and outside of any functions. (do not redeclare with var in front
inside a function if you do that)

var a=prompt("enter the password");
if (a=="noway") writeSuccess();
So, if you passed the string, it would be
writeSuccess(myhtml);
else writeFail();
}
function writeSuccess()
{
document.getElementById("writeArea").innerHTML= myhtml;
myhtml is not defined in this function.
If it were passed, it would be, or if it were global, but it is neither.

The rest looks good. :)


So, you think it's correct? Should I have any kind of consideration since I
am trying to create a character-like variable that is 16kb wide??


You are creating a string (not 'character-like'), which as far as I
know, all variables declared with "var" in javascript are actually
variants and quite large enough to hold only 16kb.
I've put a lot more than that in a string when I had to support NN4. *G*

--
--
~kaeli~
Is it true that cannibals don't eat clowns because they
taste funny?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #2
You have to be careful with your quotation and quote marks!

"Yodai" <yo***@spamnot.mail.vu> wrote in message
news:Tp***********************@telenews.teleline.e s...
Hey.... The validation system that kaeli made works smooth.... Now I was
wondering if it would be correct to make some variations to it like this:
-----original kaeli's code-------

<html>
<head>
<title> test </title>
<script type="text/javascript">
function checkLogin()
{
var a=prompt("enter the password");
if (a=="noway") writeSuccess();
else writeFail();
}
function writeSuccess()
{
document.getElementById("writeArea").innerHTML="Su ccess!";
}
function writeFail()
{
document.getElementById("writeArea").innerHTML="Fa il!";
}
</script>
</head>

<body onLoad="checkLogin()">
<div id="writeArea"></div>
</body>
</html>
-------my variations--------

<html>
<head>
<title> test </title>
<script type="text/javascript">
function checkLogin()
{
myhtml = "thewholelot of my web page from after <body> and until before
</body>
var a=prompt("enter the password");
if (a=="noway") writeSuccess();
else writeFail();
}
function writeSuccess()
{
document.getElementById("writeArea").innerHTML= myhtml;
}
function writeFail()
{
document.getElementById("writeArea").innerHTML="Wr ong password!!! Reload the page";
}
</script>
</head>

<body onLoad="checkLogin()">
<div id="writeArea"></div>
</body>
</html>
So, you think it's correct? Should I have any kind of consideration since I am trying to create a character-like variable that is 16kb wide??

Cheers!!!

Yodai

Jul 20 '05 #3

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

Similar topics

5
by: EviL KerneL | last post by:
Hi - I am trying to figure out a way to enforce the validation included for this form based on whether the user chooses "email" or "phone" as the contact choice. Right now it is set to enforce...
4
by: Tim Meagher | last post by:
I am trying to use both validation controls and to add submit button attributes, but when I add the button attributes, the javascript fpr the validation controls is no longer created for the page. ...
16
by: Hosh | last post by:
I have a form on a webpage and want to use JavaScript validation for the form fields. I have searched the web for form validation scripts and have come up with scripts that only validate...
4
by: PH | last post by:
Does anyone know how to have the pop-up javascript alert, Response.Write("<script language=javascript>alert('HEY!');</script>); , pop-up after the page has been posted back? I am pressing a...
6
by: Nedu N | last post by:
Hi, I want to have confirmation(Yes/No) on a button of the webform in which there are many validation controls. I want all the validation controls to be triggered first and then Yes/No...
4
by: usl2222 | last post by:
Hi folks, I appreciate any assistance in the following problem: I have a form with a bunch of dynamic controls on it. All the controls are dynamically generated on a server, including all...
0
by: Cleako | last post by:
Here is my dilema. I have a validation summary that I use soley for my Required Field Validators. I have it setup to run from a Page.Validate call in the code-behind, this is because I need to...
1
by: Rob | last post by:
I know this is an old one, considering how many posts I found on it but I just wondered if any best practises had popped up recently, especially as Ajax has increased JavaScript and DHTML's...
2
by: Roger | last post by:
Hi If anyone can help Is there away to make javascript prevent a postback on a button, i have tried putting the button in a <spantag with onclick but it carrys out the javascript functioon and...
3
by: Tom | last post by:
Basically I have a page that I load with 10 input fields. If users have JS enabled I want to hide 5 of these fields so as to reduce clutter. If the user needs these extra fields an "Add" button can...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.