Solved

javascript validation

Posted on 2014-09-18
2
229 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 16

Expert Comment

by:Gurpreet Singh Randhawa
ID: 40332069
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
ID: 40332097
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Find out what you should include to make the best professional email signature for your organization.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

679 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