473,785 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

check required in a select

check required in a select
how can i control if a combobox (a select) is not null (index is -1) or if
index is 0 if the first element is for example a null value or simply a
description of the field .

I try to use this

if (combobox.Selec tedIndex==0 || combobox.Select edIndex==-1)
{
alert('obbligat orio');
combobox.focus( );
combobox.select ();
}
Jul 23 '05 #1
2 3274
On Sat, 09 Oct 2004 10:43:38 GMT, SAN CAZIANO <al**********@t in.it> wrote:

[snip]
if (combobox.Selec tedIndex==0 || combobox.Select edIndex==-1)


Javascript is case-sensitive. The selectedIndex property starts with a
lowercase 's'.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #2
"SAN CAZIANO" <al**********@t in.it> wrote in message
news:uh******** ***********@new s3.tin.it...
check required in a select
how can i control if a combobox (a select) is not null (index is -1) or if
index is 0 if the first element is for example a null value or simply a
description of the field .

I try to use this

if (combobox.Selec tedIndex==0 || combobox.Select edIndex==-1)
{
alert('obbligat orio');
combobox.focus( );
combobox.select ();
}

Try this; watch for word-wrap.

<html>
<head>
<title>combobox .htm</title>
<script type="text/javascript">
function test() {
var combobox = document.form1. combo;
if (combobox.selec tedIndex <= 0) {
alert("obbligat orio");
combobox.focus( );
combobox.select edIndex = 0;
combobox.select ;
}
}
</script>
</head>
<body>
<form name="form1">
<select name="combo" size="3">
<option>
<option>1
<option>2
</select>
<input type="button" value="test()" onclick="test() ">
</form>
</body>
</html>


Jul 23 '05 #3

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

Similar topics

4
5428
by: Dmitri Shvetsov | last post by:
Hi, What methods can we use to check the integrity problems? Some records in my database are having Foreign Keys but the database doesn't have any related records with required Primary Keys. I need to scan the whole database and delete (maybe with backup, maybe not) all wrong records. Who can I do that? Is it need to write my own application to do that or we have some standard way to fix these problems? I'm not a database...
3
1623
by: frizzle | last post by:
Hi there, I'm building a multi-language PHP/mySQL -site. I'm also building a CMS for the site. There are 5 languages. In the CMS fields for e.g. english bodytext are called (id=) 'bodytext_en'. German looks like 'bodytext_ge', etc. The '_en' part tells us that it's a textfield for english texts.
1
1079
by: Michelle A. | last post by:
I have a 4 page form. First page has a series of check boxes of different "opportunities" to select from. These check boxes are optional but they have to at least select one (or fill in the other text box) before they can go on to step two. I tried to add a required field validate to this, however I am not sure how this would work since I cannot select any of the check boxes from the "ControlToValidate" property.
1
4238
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get the example to work. I created the following two classes, provided with the example: *-*-**-*-*-*-*-*-*-*-*-*-**-*-*-*-*-CheckBoxColumn Class:-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-**-*-*-*
4
4184
by: tshad | last post by:
What would be a good way to check programmatically whether a service was running? We have a service that dies periodically and I need to check to see if this service is running. I know how to check to see if the status is in stopped or running mode. But that doesn't tell me if it is actually running. I need to know this so that if it happens I can programmatically start the same service on another machine.
11
3997
by: Naeem | last post by:
I have a Javascript function, which changes a text field of a form into a select field. Following is the function function changeStateField() { var myForm = document.getElementsByTagName("form"); alert(myForm.stateId.value); myForm.removeChild(myForm.stateId);
4
3527
by: JBiggsCC | last post by:
I have a very simple login page which takes an ID number via a HTML form GET. What is easiest way to check that ID number against an Access DB to see if it exists? I want to redirect with the ID in the query string if it does exist and have them re-enter if incorrect.
3
4713
by: Search & You Will Find | last post by:
I have a database in Access 2000 that I need some help on. I have three tables: PROJECTS, SYSTEMS, & SYSTEMSREF. They possess the following fields: ----------------------------------- PROJECTS project_pk (autonumber) project_name
0
1597
by: readnlearn | last post by:
hai, i have written this below code for displaying captcha image whenever i entered incorrect uname,password in login page. for that i disable the controls of captcha like textbox,labels,button and image control in source code of designing part. and i enable those controls in an if condition which display captcha. but if i entered correct information which is in database it shouldn't navigate to the corresponding page and also if entered...
0
9646
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
9484
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
10157
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...
0
9957
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
8983
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
7505
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...
1
4055
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
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.