Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Validate select box or drop down

Enthusiast ,
May 29, 2007 May 29, 2007
I need scipt to validate select box or drop down for DW8 ASP or Javascript, as validate form behavior doen't do it. Thanks
TOPICS
Server side applications
362
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 29, 2007 May 29, 2007
It all depends upon what you want to validate. The check form from
www.yaromat.com has the option to check that the first item in a dropdown is
not selected.

--
Paul Whitham
Certified Dreamweaver MX2004 Professional
Adobe Community Expert - Dreamweaver

Valleybiz Internet Design
www.valleybiz.net

"MikeL7" <webforumsuser@macromedia.com> wrote in message
news:f3i46g$n0e$1@forums.macromedia.com...
>I need scipt to validate select box or drop down for DW8 ASP or Javascript,
>as validate form behavior doen't do it. Thanks


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 01, 2007 Jun 01, 2007
LATEST
You can use this Javascript to check if any option of a select has been selected:

if (document.formname.fieldname.selectedIndex < 0) {
alert("Fieldname is required.");
return false;}
return true;

where formname is the name of the form, and fieldname is the name of the select. The alert pops up the error message, and the "return false;" prevents the form from being submitted. Put this code in a Javascript function that you call from onsubmit in the form tag, like so:

onsubmit="return functionname();"
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines