Solved

javascript validation

Posted on 2014-09-18
2
226 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: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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

862 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

25 Experts available now in Live!

Get 1:1 Help Now