473,671 Members | 2,367 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

please help with JavaScript Form !

Hello Everyone!

Could someone please have a look at my JS Form I posted
below....Someth ing wrong there, but I don't understand what's exactly.

Many thanks.
Olly

=============== =============== =
<script language="JavaS cript">

function checkChars(fiel d, fieldName) {

var okchars =
"0123456789abcd efghijklmnopqrs tuvwxyzABCDEFGH IJKLMNOPQRSTUVW XYZ@.-"
var ok = "yes";
var temp;

for (var i = 0; i < field.value.len gth; i++) {
temp = "" + field.value.sub string(i, i+1);
if (okchars.indexO f(temp) == "-1") ok = "no";
}

if (ok == "no") {
alert("The " + fieldName + " field must contain only alphabetic or
numeric characters, please check for invalid characters.");
field.focus();
field.select();

}

}

function valForm2(theFor m){
var ps = document.Form2. single_pw.value ;

var theAction = "http://vubiz.com/default.asp?vcu st=CCHS2544&vId =" +
ps +
"&vSource=h ttp://ccohs.ca/products/coursesNew/loginnewforall. html";
document.Form2. target = "_blank";
history.go(0);
if (ps == "") {
alert("Please enter your password.");
document.Form2. single_pw.focus ();
}
else {
document.Form2. action = theAction;
document.Form2. submit();
}
}

function valForm3(theFor m){
var mps = document.Form3. multi_pw.value;
var custID = document.Form3. Cust.value;

var theAction = "http://vubiz.com/v5/default.asp?vCu st=" + mps +
"&vId=" + custID + "&vLang=EN" +
"&vSource=h ttp://ccohs.ca/products/coursesNew/loginnewforall. html";
document.Form3. target = "_blank";
history.go(0);

if (mps == "") {
alert("Please enter your password.");
document.Form3. multi_pw.focus( );
}
else if (Cust == "") {
alert("Please enter your Customer ID.");
}
else {
document.Form3. action = theAction;
document.Form3. submit();
}

}

</script>
=============== ==
<div align="center">

<table border="0" cellpadding="10 " cellspacing="0" width="60%">
<TR>
<TD ALIGN="left" class="bodytext " colspan="3"><st rong>Single User
Login :</strong></TD>
</TR>
<TR><form name="Form2" action="javascr ipt:valForm2('F orm2');"
method="post">
<TD ALIGN="center" class="bodytext ">Password: </TD>
<TD ALIGN="left"><i nput type="password" name="single_pw " size="10"
onBlur="checkCh ars(this, 'Password');">
</TD>

<TD ALIGN="left"><i nput type="image" src="/images/login_on_grey.g if"
width="75" height="17" border="0" value="Link to Login page"
alt="Login"></TD>
</TR>
<TR>
<TD>&nbsp;</TD>
</TR>
</form>
<form name="Form3" action="javascr ipt:valForm3('F orm3');"
method="post">
<TR>
<TD ALIGN="left" class="bodytext " colspan="3"><st rong>Multi User
License Login :</strong></TD>

</TR>
<TR>
<TD ALIGN="center" class="bodytext ">Customer ID:</TD>
<TD ALIGN="left"><i nput type="text" name="Cust" size="10">
</TD>
<TD ALIGN="left">&n bsp;</TD>
</TR>
<TR>

<TD ALIGN="center" class="bodytext ">Password: </TD>
<TD ALIGN="left"><i nput type="password" name="multi_pw" size="10"
onBlur="checkCh ars(this, 'Password');">
</TD>
<TD ALIGN="left"><i nput type="image" src="/images/login_on_grey.g if"
width="75" height="17" border="0" value="Link to Login page"
alt="Login"></TD>
</TR>
<TR>
<TD>&nbsp;</TD>
</TR>

</form>

</table>
</div>

Jun 2 '06 #1
5 2520
Olly said:
Hello Everyone!

Could someone please have a look at my JS Form I posted
below....Someth ing wrong there, but I don't understand what's exactly.

Many thanks.
Olly


It would help if you included some information about what's wrong. E.g.
say what's supposed to happen and say what does happen instead. and/or use
your browser's javascript debugging capabilities to report any errors in
the page. (In firefox 1.5 it's tools -> Javascript console)

--
http://www.niftybits.ukfsn.org/

remove 'n-u-l-l' to email me. html mail or attachments will go in the spam
bin unless notified with [html] or [attachment] in the subject line.

Jun 2 '06 #2
Hi Andy:

Thanks for answering my call for help. :-)
It would help if you included some information about what's wrong. E.g.
say what's supposed to happen and say what does happen instead. and/or use
your browser's javascript debugging capabilities to report any errors in
the page. (In firefox 1.5 it's tools -> Javascript console)
This is Login page with three text fields in it - Password for Single
User, Password for Multi User and Customer ID for Multi-User, and two
Login buttons (for Single Users and Multi Users). I use two separate
forms on that page (one for Single Users, another - for Multi Users).
Once users click on any of the Login buttons, they're redirected to
external web site.
All three text fields are mandatory, but for some reason function
responsible for Multi Users mandatory fields (Password and Customer ID)
is not working properly. When I troubleshooted this page in Firefox, I
got message saying that my form for Multi Users is not defined. I
suspect, something wrong with my "if, else if" part of the Multi Users
script where I check if users filled in Multi Users fields.

Hope this info was more helpful.

Again, I appreciate your willingness to get me out of that mud.

Regards,
Olly

Andy Baxter wrote: Olly said:
Hello Everyone!

Could someone please have a look at my JS Form I posted
below....Someth ing wrong there, but I don't understand what's exactly.

Many thanks.
Olly


It would help if you included some information about what's wrong. E.g.
say what's supposed to happen and say what does happen instead. and/or use
your browser's javascript debugging capabilities to report any errors in
the page. (In firefox 1.5 it's tools -> Javascript console)

--
http://www.niftybits.ukfsn.org/

remove 'n-u-l-l' to email me. html mail or attachments will go in the spam
bin unless notified with [html] or [attachment] in the subject line.


Jun 3 '06 #3
Olly said:
Hi Andy:

Thanks for answering my call for help. :-)
It would help if you included some information about what's wrong. E.g.
say what's supposed to happen and say what does happen instead. and/or use
your browser's javascript debugging capabilities to report any errors in
the page. (In firefox 1.5 it's tools -> Javascript console)


This is Login page with three text fields in it - Password for Single
User, Password for Multi User and Customer ID for Multi-User, and two
Login buttons (for Single Users and Multi Users). I use two separate
forms on that page (one for Single Users, another - for Multi Users).
Once users click on any of the Login buttons, they're redirected to
external web site.
All three text fields are mandatory, but for some reason function
responsible for Multi Users mandatory fields (Password and Customer ID)
is not working properly. When I troubleshooted this page in Firefox, I
got message saying that my form for Multi Users is not defined. I
suspect, something wrong with my "if, else if" part of the Multi Users
script where I check if users filled in Multi Users fields.

Hope this info was more helpful.

Again, I appreciate your willingness to get me out of that mud.

Regards,
Olly


Could you say what the exact error message was? Also, does the page work
in IE6? And does the first form work OK? I think (someone correct me
if I'm wrong) that the syntax you are using for getting at the form
element (document.Form3 .) is a peculiarity of internet explorer, and isn't
widely supported. So maybe try using:

var form3=null;
var multiPw=null;
if (document.getEl ementById) {
form3=document. getElementById( "form3");
multiPw=documen t.getElementByI d("multi_pw") ;
}
Form3.target = "_blank";
......
multi_pw.focus( )
.... etcetera

--
http://www.niftybits.ukfsn.org/

remove 'n-u-l-l' to email me. html mail or attachments will go in the spam
bin unless notified with [html] or [attachment] in the subject line.

Jun 3 '06 #4
JRS: In article <11************ ********@i39g20 00cwa.googlegro ups.com>,
dated Fri, 2 Jun 2006 14:10:42 remote, seen in
news:comp.lang. javascript, Olly <ol******@yahoo .com> posted :
<script language="JavaS cript">
Deprecated.
function checkChars(fiel d, fieldName) {

var okchars =
"0123456789abc defghijklmnopqr stuvwxyzABCDEFG HIJKLMNOPQRSTUV WXYZ@.-"
var ok = "yes";
var temp;

for (var i = 0; i < field.value.len gth; i++) {
temp = "" + field.value.sub string(i, i+1);
Consider method charAt.
if (okchars.indexO f(temp) == "-1") ok = "no";
}

if (ok == "no") {
alert("The " + fieldName + " field must contain only alphabetic or
numeric characters, please check for invalid characters.");
field.focus();
field.select();

}

}


Consider
var BAD = /[^a-z0-9@.-]/i.test(field.va lue) // by RegExp
if (BAD) { ...

Code should not be allowed to be wrapped by your posting agent; code as
displayed to us should be both executable and readable.

Avoid naive "validation " of E-addresses.

Read the newsgroup FAQ.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jun 3 '06 #5
Thanks Andy and John!

Here's URL for this page.
http://ccohs.ca/products/coursesNew/mylogin.html

I opened Firfox's JS console and got not error messages.The first form
seems to be working fine, but not the second one. I suspect something
wrong with the conditionals in the second form....

Regards.
Olly

Andy Baxter wrote:
Olly said:
Hi Andy:

Thanks for answering my call for help. :-)
It would help if you included some information about what's wrong. E.g.
say what's supposed to happen and say what does happen instead. and/or use
your browser's javascript debugging capabilities to report any errors in
the page. (In firefox 1.5 it's tools -> Javascript console)


This is Login page with three text fields in it - Password for Single
User, Password for Multi User and Customer ID for Multi-User, and two
Login buttons (for Single Users and Multi Users). I use two separate
forms on that page (one for Single Users, another - for Multi Users).
Once users click on any of the Login buttons, they're redirected to
external web site.
All three text fields are mandatory, but for some reason function
responsible for Multi Users mandatory fields (Password and Customer ID)
is not working properly. When I troubleshooted this page in Firefox, I
got message saying that my form for Multi Users is not defined. I
suspect, something wrong with my "if, else if" part of the Multi Users
script where I check if users filled in Multi Users fields.

Hope this info was more helpful.

Again, I appreciate your willingness to get me out of that mud.

Regards,
Olly


Could you say what the exact error message was? Also, does the page work
in IE6? And does the first form work OK? I think (someone correct me
if I'm wrong) that the syntax you are using for getting at the form
element (document.Form3 .) is a peculiarity of internet explorer, and isn't
widely supported. So maybe try using:

var form3=null;
var multiPw=null;
if (document.getEl ementById) {
form3=document. getElementById( "form3");
multiPw=documen t.getElementByI d("multi_pw") ;
}
Form3.target = "_blank";
.....
multi_pw.focus( )
... etcetera

--
http://www.niftybits.ukfsn.org/

remove 'n-u-l-l' to email me. html mail or attachments will go in the spam
bin unless notified with [html] or [attachment] in the subject line.


Jun 5 '06 #6

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

Similar topics

2
1893
by: kevin | last post by:
hi there I am struggling with javascript. Can you please help me I've managed to get the get URL in flash to open a html that has the function that opens the Feedback form I want. I Couldn't get the feedback form to load directly from the flash because I had to use the function in dreamweaver that opens it with the specifications I wanted. That being just a simple box with no menus etc...
6
1785
by: James Walker | last post by:
Can some one help I get an error of 'checkIndate' is null or not an object can someone please help. I can't work out why Thanks in advance James <form> <td height="24" colspan="7" valign="top"><form name="booknow"><select
5
2278
by: TrvlOrm | last post by:
Can any one please help me...I am new to JavaScript and I have been struggling with this code for days now and can't figure it out. I would like to get the Buttons to correspond with the action to either a) generate numbers b) Prompts a user to locate a web page c) go to previous page in history list d) Loads next page in history list e) Promps the user for a URL and loads the web page in a new window f) and Re-Sizes the window. ...
7
3598
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title> </head> <style type="text/css">
11
1912
by: milkyway | last post by:
Hello, I have an HTML page that I am trying to import 2 .js file (I created) into. These files are: row_functions.js and data_check_functions.js. Whenever I bring the contents of the files into this HTML file, all is OK but whenever the functions are separated (as it is now), when I run the page, I get the following error: Line 73, object expected.
1
2167
by: dreamlab | last post by:
Hello, Can one of you javascript wizards help out a newbie, please? I’ve got a formHandler that is supposed to check for a good email address and name in the form after clicking the submit link and display a status error message above the form if either the E-mail and/or Name fields are blank, but instead the page does nothing. I think that the Submit link in the code below is probably the root of the problem: <a href="javascript:;"...
5
2579
by: settyv | last post by:
Hi, Below is the Javascript function that am trying to call from asp:Button control. <script language="javascript"> function ValidateDate(fromDate,toDate) { var fromDate=new Date();
1
1832
by: theflyingminstrel | last post by:
Hi, I’m having some trouble with a Javascript code, and I was wondering if anyone can help: I am trying to build a price estimator that has multiple fields. I would like the first two fields to have a price value based on a quantity price, so for example 1-10 qantity equals $30, 20-30 quantity equals $40 in the “Total” field). The rest of the fields in the following code work as intended whereas they just add based on the price to the right....
0
8472
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
8390
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8909
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...
1
8596
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8667
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...
0
7428
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6222
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
4399
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2806
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

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.