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

please help with JavaScript Form !

Hello Everyone!

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

Many thanks.
Olly

===============================
<script language="JavaScript">

function checkChars(field, fieldName) {

var okchars =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLM NOPQRSTUVWXYZ@.-"
var ok = "yes";
var temp;

for (var i = 0; i < field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (okchars.indexOf(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(theForm){
var ps = document.Form2.single_pw.value;

var theAction = "http://vubiz.com/default.asp?vcust=CCHS2544&vId=" +
ps +
"&vSource=http://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(theForm){
var mps = document.Form3.multi_pw.value;
var custID = document.Form3.Cust.value;

var theAction = "http://vubiz.com/v5/default.asp?vCust=" + mps +
"&vId=" + custID + "&vLang=EN" +
"&vSource=http://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"><strong>Single User
Login :</strong></TD>
</TR>
<TR><form name="Form2" action="javascript:valForm2('Form2');"
method="post">
<TD ALIGN="center" class="bodytext">Password:</TD>
<TD ALIGN="left"><input type="password" name="single_pw" size="10"
onBlur="checkChars(this, 'Password');">
</TD>

<TD ALIGN="left"><input type="image" src="/images/login_on_grey.gif"
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="javascript:valForm3('Form3');"
method="post">
<TR>
<TD ALIGN="left" class="bodytext" colspan="3"><strong>Multi User
License Login :</strong></TD>

</TR>
<TR>
<TD ALIGN="center" class="bodytext">Customer ID:</TD>
<TD ALIGN="left"><input type="text" name="Cust" size="10">
</TD>
<TD ALIGN="left">&nbsp;</TD>
</TR>
<TR>

<TD ALIGN="center" class="bodytext">Password:</TD>
<TD ALIGN="left"><input type="password" name="multi_pw" size="10"
onBlur="checkChars(this, 'Password');">
</TD>
<TD ALIGN="left"><input type="image" src="/images/login_on_grey.gif"
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 2500
Olly said:
Hello Everyone!

Could someone please have a look at my JS Form I posted
below....Something 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....Something 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.getElementById) {
form3=document.getElementById("form3");
multiPw=document.getElementById("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********************@i39g2000cwa.googlegroups.c om>,
dated Fri, 2 Jun 2006 14:10:42 remote, seen in
news:comp.lang.javascript, Olly <ol******@yahoo.com> posted :
<script language="JavaScript">
Deprecated.
function checkChars(field, fieldName) {

var okchars =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKL MNOPQRSTUVWXYZ@.-"
var ok = "yes";
var temp;

for (var i = 0; i < field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
Consider method charAt.
if (okchars.indexOf(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.value) // 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.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.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.getElementById) {
form3=document.getElementById("form3");
multiPw=document.getElementById("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
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...
6
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"...
5
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...
7
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>...
11
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...
1
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...
5
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
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...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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.