473,789 Members | 2,781 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help with syntax in form validation

Hello,

I am trying to make use of the following:

function checkIt(){
if (document.PRODA DD.AttributeVal ue[1].value == "") { //validate month
select
alert("Please select an option!");
document.myForm .ExpMonth.focus ();
return false;

}
if (document.PRODA DD.AttributeVal ue[41].value == "") { //validate year
select
alert("Please select an option");
document.myForm .ExpYear.focus( );
return false;
}
return true;
}
And then later of course is:

<FORM NAME="PRODADD" METHOD="post" ACTION="../prodadd.asp" onsubmit="retur n
checkIt();">

The first problem is that javascript does not seem to like

AttributeValue[1]
AttributeValue[41]

Those are the select names in the form as in:

<SELECT NAME="Attribute Value[41]">

The [ and ] characters seem to be causing a choke. If I remove them from
the javascript function and the select names it works. If I put them back
I get this error:

document.PRODAD D.AttributeValu e.1 is null or not an object.

I *have* to keep those brackets in the select name area of the form. I
assume it is a matter of changing the syntax up in the function to properly
"see" them?

Problem #2 is that even when the function works the form submits as soon as
you OK the alert popup. How do I halt that?

Thank you very much.
May 4 '06 #1
4 1440
Oops sorry. I figured out part 2, keeping the form from submitting after
the alert. My fault there, forgot to update the function here:

document.myForm .ExpMonth.focus ()

and here:

document.myForm .ExpYear.focus( )

Those were holdovers from the original I found online.

But the problem with the [ ] causing a choke still stands.
Hello,

I am trying to make use of the following:

function checkIt(){
if (document.PRODA DD.AttributeVal ue[1].value == "") { //validate month
select
alert("Please select an option!");
document.myForm .ExpMonth.focus ();
return false;

}
if (document.PRODA DD.AttributeVal ue[41].value == "") { //validate year
select
alert("Please select an option");
document.myForm .ExpYear.focus( );
return false;
}
return true;
}
And then later of course is:

<FORM NAME="PRODADD" METHOD="post" ACTION="../prodadd.asp"
<onsubmit="ret urn
checkIt();">

The first problem is that javascript does not seem to like

AttributeVal ue[1]
AttributeVal ue[41]

Those are the select names in the form as in:

<SELECT NAME="Attribute Value[41]">

The [ and ] characters seem to be causing a choke. If I remove them
from the javascript function and the select names it works. If I put
them back I get this error:

document.PRODA DD.AttributeVal ue.1 is null or not an object.

I *have* to keep those brackets in the select name area of the form. I
assume it is a matter of changing the syntax up in the function to
properly "see" them?

Problem #2 is that even when the function works the form submits as soon
as you OK the alert popup. How do I halt that?

Thank you very much.


May 4 '06 #2
Alan Edmund said on 04/05/2006 2:53 PM AEST:
Hello,

I am trying to make use of the following:

function checkIt(){
if (document.PRODA DD.AttributeVal ue[1].value == "") { //validate month ------------------------------------^^^^

if (document.PRODA DD['AttributeValue[1]'].value == "") { ...
The way you have written it, you are looking for an array or collection
called document.PROADD .AttributeValue that has a member at index 1.

<URL;http://www.jibbering.c om/faq/#FAQ4_39>

[...]

I *have* to keep those brackets in the select name area of the form. I
assume it is a matter of changing the syntax up in the function to properly
"see" them?


Yes. Read the above reference and the link below on useage of square
brackets.

<URL:http://www.jibbering.com/faq/faq_not..._brackets.html >

[...]
--
Rob
Group FAQ: <URL:http://www.jibbering.c om/FAQ>
"It is much easier for a web developer to create a site
that receives no complaints than to create a site that
doesn't warrant any."--Richard Cornford
May 4 '06 #3
RobG said on 04/05/2006 3:45 PM AEST:
Alan Edmund said on 04/05/2006 2:53 PM AEST:
Hello,

I am trying to make use of the following:

function checkIt(){ if (document.PRODA DD.AttributeVal ue[1].value ==

--------------------------------------------------------^^^


That should of course be highlighting the [1].
--
Rob
Group FAQ: <URL:http://www.jibbering.c om/FAQ>
May 4 '06 #4
ASM
Alan Edmund a écrit :
Hello,

I am trying to make use of the following:
I prefer to use a generic way

function checkAll(myForm ) {
var txt = 'You have not answered the field : ';
for(var i=0;i<myForm.le ngth;i++) if(myForm[i].value=='') {
alert(txt+myFor m[i].name);
myForm[i].focus();
return false;
}
return true;
}

<FORM NAME="PRODADD" onsubmit="retur n checkAll(this.f orm);" ... >

function checkIt(){
if (document.PRODA DD.AttributeVal ue[1].value == "")
if (document.PRODA DD['AttributeValue[1]'].value == "")
or
if (document.PRODA DD.elements['AttributeValue[1]'].value == "")

{ //validate month select
alert("Please select an option!");
document.myForm .ExpMonth.focus ();
return false;
} Problem #2 is that even when the function works the form submits as soon as
you OK the alert popup. How do I halt that?


the onsubmit from form returns result of your check function
if one element was not seen this function does following :
- alert (alert stops everything durind its display)
- scrolls page to the element
- return false ==>
- return = end of this function
- false = form's action disabled (it is not send)

--
Stephane Moriaux et son [moins] vieux Mac
May 4 '06 #5

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

Similar topics

9
2718
by: Pemburger | last post by:
From: pemburger@aol.com I've tried the W3C MarkUp Validation Service for the following web page: http://www.coverscript.com The report given by W3C shows 300 plus errors? I am not able to understand their explanations on the errors. As per W3C's info that if I am having problems with validation -- try for some
1
2014
by: Brad Hehe | last post by:
I am attempting to use XPath to query for a specific node in the sample XML I've provided below. I'm unsure of the exact XPath syntax, but I believe I need the following query to get the proper node where the node value contains a specific value: /FYIFORM/TEMPLATEINFO/FIELD = "THE FORM I WANT"
2
4038
by: qsweetbee | last post by:
I have a form(fAddUsers) in my database. It is continue form for data entry. Some fields are required fields. Some are optional fields. There is 1 particular filed(TokenExpirationDate)on the form which is depended on the other field(TokenID)whether it is blank or not. If the "TokenID" field is blank, the "TokenExpirationDate" field can be blank also. But if the "TokenID" field is not blank or null, the "TokenExpirationDate" field must be...
2
1633
by: Paul | last post by:
Hi, I hope somebody can help me with the following. (I have tried searching for a solution on the newsgroups but nothing is quite what I need. Feel free to point me in the direction of anything I may have missed though.) I have a form with 2 text boxes, two list boxes and 2 buttons (A & B). Both buttons must perform some validation but they differ in their extent. Button A must ensure that a date has been entered in both text
7
1482
by: phillip.s.powell | last post by:
Now I have another SQL query for MySQL I can't figure out!! This is overwhelming me completely and I also must have this figured out today and I can't figure it out!! UPDATE student_db.student SET has_letter1 = ( SELECT i.letter1 FROM olddb.student i, student_db student s WHERE s.unique_key = i.unique_key )
36
3111
by: aljamala | last post by:
Hi, I keep getting this warning on a page, but I do not know what the problem is...does anyone have an idea about what could be wrong? line 88 column 7 - Warning: missing </formbefore <td> it highlights this line: <form name="frmCurrency" action="" method="post"> Page source....
0
5576
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
3
2265
by: Birky | last post by:
Hello, I’m hoping you can help me out with two issues I’m having with my code. I have an Access Report named Report_Project_Event_Log which I have calling a Form named “Custom_Code_lookup” which allows a user to select data for the report. I have a hidden txt object within this form named txtContinue which is either set to “no” or “yes”. I believe I have everything running correctly except for my cancel code below. When the Cancel button is...
2
1834
by: Joey | last post by:
Hello guys, I'm trying to learn about regular expressions. I need to be able to use an RE that can evaluate for STRINGS (or specific sequences of characters), not just occurances of characters. Everything I have read thus far involves checking only for the presence or absence of characters. Can anyone provide an RE that will correctly evaluate a string to see if it contains other strings, specifically these (omit the quotes)..."<script>",...
0
10410
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
10200
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...
1
10139
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
9984
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
9020
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
7529
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
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4093
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
3701
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.