473,406 Members | 2,220 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,406 software developers and data experts.

Calling a function...

DSL
I'm pulling my little hair that's left out trying to figure out how I can
call a function from within a function. Here's the deal... and yes I know I
should be using PHP!

I have a password login screen for three users who have individual
pre-assigned passwords so i need some logic testing as per below
// ========START OF CODE=========

//This is the function to find out who is logging in
function validate()
{
//Change case from the input
var usrid=document.form.usrid.value.toLowerCase()

//Simple if statement for the who's logging in logic
if(usrid=="TEST") //**??THIS IS WHERE I HAVE PROBLEM 1 (FOR
SURE)??**
else
if(usrid=="") alert("ID REQUIRED!")
}

//This is the password check for the user TEST
function validateTESTIDPwd()
{
//Change case from the input
var pwd=document.form.pwd.value.toLowerCase()

//Validate password
if(pwd=="TEST") //**?? THIS IS WHERE I HAVE PROBLEM 2 (MAYBE)??**
else
alert("Password Incorrect!")
}

// ========END OF CODE=========

OK, so problem 1: How can I call the validateTESTIDPwd() function
and problem 2: After confirming the identity of user TEST I want to open up
a page in the current frame. Does anyone know how to manipulate my frames
from this point?

All help appreciated.

Cheers,

Matt
Jul 23 '05 #1
2 1216
DSL wrote:
function popup(txt){alert(txt)}
function validateTESTIDPwd(){
if(document.form.pwd.value.toLowerCase()=="test"){
popup("Password Correct");
return;
}
alert("Password Incorrect!")
}

Mick
Jul 23 '05 #2
In article <c6**********@sparta.btinternet.com>,
"DSL" <ma***********@btinternet.com> wrote:
I'm pulling my little hair that's left out trying to figure out how I can
call a function from within a function. Here's the deal... and yes I know I
should be using PHP!
What is the point of check the userid & password in javascript? The
user can just read the javascript code.
I have a password login screen for three users who have individual
pre-assigned passwords so i need some logic testing as per below
OK, so problem 1: How can I call the validateTESTIDPwd() function
and problem 2:


Below is an example of checking the userid. The code of the HTML form
could be improved, but it demonstrates what you need.

Robert

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Chapter 4 - Scripting Exercise 5</title>

<SCRIPT type="text/javascript">

//This is the function to find out who is logging in
function validate(userid)
{
alert("Checking for " + userid);
// Change case from the input
// -- so you need to check in lower case
var userid=userid.toLowerCase()

//Simple if statement for the who's logging in logic
if(userid=="test")
{
// Suggest you put the trailing if code in a block.
// It's ease to forget when adding a line.
alert(userid + " is a valid userid");
return true
}
else
if(userid=="")
{
// Tell the user how to fix the problem not what is wrong.
alert("Please enter a valid userid");
return false
}
else
{
alert("Please enter a valid userid. This one is not known.");
return false
}
}
</script>

</head>
<body>
<form action="" method="post" name="submituserid"
onSubmit="answer = validate(document.forms[0].theUserid.value);
alert('valid user = ' + answer);">
<b>What is your userid?&nbsp&nbsp
<input type="text" id="theUserid" size="10" maxlength="16"><br>
<input type="submit" name="submit" value="Check userid"><br>
<input type="reset" name="reset" value="Reset Form">
</form>
</body>
</html>
Jul 23 '05 #3

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

Similar topics

8
by: Muthu | last post by:
I've read calling conventions to be the order(reverse or forward) in which the parameters are being read & understood by compilers. For ex. the following function. int Add(int p1, int p2, int...
6
by: jchao123 | last post by:
Dear All, I have an MDB file (Access 2000/XP) which contains generic routines I use in various apps (eg, API calls, File access classes etc). I have compiled into an MDE file which I reference...
14
by: ericellsworth | last post by:
Hi, I'm trying to use a class to pass variables back and forth from a form opened in dialog mode. I have created a class which invokes a form in its show method, like so: Public Sub Show() '...
1
by: Jesse McGrew | last post by:
Hi all, I'm trying to make a plugin DLL for a third-party application, using VC++ .NET 2003. This DLL acts as a bridge between the C++ plugin API of the application, and my actual plugin code...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
2
by: Geler | last post by:
A theoretical question: Sorry if its a beginner question. Here is a quote from the MSDN explaning the C/C++ calling convention.. It demonstrates that the calling function is responsible to clean...
18
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I...
15
by: dspfun | last post by:
Hi, Is it possible to print the function name of the calling function? For example, f1() and f2() both calls f3(), in f3() I would like to print the name of the function calling f3() which...
11
by: briankirkpatrick | last post by:
Forgive me if my post seems a little amateurish... I'm requesting assistance from some of you smart folks out there to get the managed calls write that meet the specification in the esa.h for...
16
by: teju | last post by:
hi, i am trying 2 merge 2 projects into one project.One project is using c language and the other one is using c++ code. both are working very fine independently.But now i need to merge both...
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...
0
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,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.