Solved

javascript validation

Posted on 2014-09-18
2
225 Views
Last Modified: 2014-09-24
I am trying to validate the dropdwon that consists states and I also do the brake down by country. So when I select Select option it is validating properly , if I do select United State it does not validate at all

<select name="state" id="state" class="textbox">
   <option value="" <cfif attributes.SelectedState eq "">selected</cfif>>-- Select -- </option>
   <option value="" >--United States--</option>
   <option value="AL"  <cfif attributes.SelectedState eq "AL">selected</cfif>>Alabama </option>

</select>

if (validate[i].ruleType == "selectReq") {
				
				if (valueSelect(validate[i].fieldName) == false) {
					alert(validate[i].alertText);
					thisField.focus();
					Passed = false;
					break;
					break;
				}
			}

Open in new window

0
Comment
Question by:erikTsomik
2 Comments
 
LVL 15

Expert Comment

by:myselfrandhawa
Comment Utility
is this a complete code?

You can pass 0 to the united states and add on emore condition using the

if (valueSelect(validate[i].fieldName) == false || valueSelect(validate[i].fieldName) == 0) {

Open in new window

0
 
LVL 15

Accepted Solution

by:
Insoftservice earned 500 total points
Comment Utility
Please provide complete code.

   <option value="" <cfif attributes.SelectedState eq "">selected</cfif>>-- Select -- </option>
   <option value="" >--United States--</option>
   <option value="AL"  <cfif attributes.SelectedState eq "AL">selected</cfif>>Alabama </option>

values for both united states and Select is same.
Please change it to below and try, just alert what value you get when you change the select option
   <option value="0" <cfif attributes.SelectedState eq "">selected</cfif>>-- Select -- </option>
   <option value="US" >--United States--</option>
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now