Attached the proof when we select the USA from country Drop Down The state label should be required.
Revision 1130465 of Firefox Developer Tools
Revision Information
- Revision slug: Tools
- Revision title: Firefox Developer Tools
- Revision id: 1130465
- Created:
- Creator: saiT56
- Is current revision? No
- Comment
Tags:
Revision Content
Revision Source
<div class="column-container zone-callout"> <p><a href="https://www.mozilla.org/en-US/firefox/developer/" style="float: right; margin-bottom: 20px; padding: 10px; text-align: center; border-radius: 4px; display: inline-block; background-color: #81BC2E; white-space: nowrap; color: white; text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.25); box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.2), 0px -1px 0px 0px rgba(0, 0, 0, 0.3) inset;" target="_">Question is Suppose we have two Dropdown.<br /> One Dropdown name is Country and it contains all the country names and we have another Dropdown and that Dropdown name is state it contains all the state names. Problem is when we select country Dropdown in that if we select country as USA the state should become mandatory. For other countries it should be not mandatory. For only selecting USA in country Dropdown , state should become mandatory for other countries it should be not mandatory. </a></p> <p><a href="https://www.mozilla.org/en-US/firefox/developer/" style="float: right; margin-bottom: 20px; padding: 10px; text-align: center; border-radius: 4px; display: inline-block; background-color: #81BC2E; white-space: nowrap; color: white; text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.25); box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.2), 0px -1px 0px 0px rgba(0, 0, 0, 0.3) inset;" target="_">Attaching the code for the same.<br /> [Code.txt](https://github.com/cluj-javascripters/community-help/files/531141/Code.txt)</a></p> <p><a href="https://www.mozilla.org/en-US/firefox/developer/" style="float: right; margin-bottom: 20px; padding: 10px; text-align: center; border-radius: 4px; display: inline-block; background-color: #81BC2E; white-space: nowrap; color: white; text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.25); box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.2), 0px -1px 0px 0px rgba(0, 0, 0, 0.3) inset;" target="_">Below is my code</a></p> <p><a href="https://www.mozilla.org/en-US/firefox/developer/" style="float: right; margin-bottom: 20px; padding: 10px; text-align: center; border-radius: 4px; display: inline-block; background-color: #81BC2E; white-space: nowrap; color: white; text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.25); box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.2), 0px -1px 0px 0px rgba(0, 0, 0, 0.3) inset;" target="_"><html><br /> <head><br /> <title></title><br /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><br /> <script src="https://code.jquery.com/jquery-3.1.1.slim.min.js"></script><br /> <script type='text/javascript'>//<![CDATA[<br /> $(document).ready(function(){<br /> $('select[name=country]').change(function () {<br /> if ($(this).val() == 'United States') {<br /> $('.control').show();<br /> $('.control').prop('required',true);<br /> alert ('State is required')<br /> } else {<br /> $('.control').prop('required',false);<br /> $('.control').show();<br /> }<br /> });<br /> })<br /> </script><br /> <!--Country select--><br /> <label for="SelectCountry" class="control-test">Country:</label> <select class="countrycss" id="country" name="country" ><br /> <option value="" selected="selected">Please Select Country</option><br /> <option value="Canada" id="Canada">Canada</option><br /> <option value="United States" id="United States">United States</option><br /> </select><br /> <br><br /> <br><br /> <br><br /> <!--State select--><br /> <div id="stateselect" ><br /> <label for="stateselect" class="control" >State :</label> </a></p> <p><a href="https://www.mozilla.org/en-US/firefox/developer/" style="float: right; margin-bottom: 20px; padding: 10px; text-align: center; border-radius: 4px; display: inline-block; background-color: #81BC2E; white-space: nowrap; color: white; text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.25); box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.2), 0px -1px 0px 0px rgba(0, 0, 0, 0.3) inset;" target="_"> <select class="statecss" id="state" name="state" required><br /> <option value="" selected="selected">Please Select State</option><br /> <option value="Arkansas" id="Arkansas">Alaska</option><br /> <option value="Hawalli" id="Hawalli">Hawalli</option><br /> </select><br /> </div><br /> </body><br /> </html></a></p> <p><br /> <a href="https://www.mozilla.org/en-US/firefox/developer/" style="float: right; margin-bottom: 20px; padding: 10px; text-align: center; border-radius: 4px; display: inline-block; background-color: #81BC2E; white-space: nowrap; color: white; text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.25); box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.2), 0px -1px 0px 0px rgba(0, 0, 0, 0.3) inset;" target="_">![required](https://cloud.githubusercontent.com/assets/22855265/19410296/e4a27078-9305-11e6-9c30-f733459158fe.png)</a></p> <p><br /> <a href="https://www.mozilla.org/en-US/firefox/developer/" style="float: right; margin-bottom: 20px; padding: 10px; text-align: center; border-radius: 4px; display: inline-block; background-color: #81BC2E; white-space: nowrap; color: white; text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.25); box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.2), 0px -1px 0px 0px rgba(0, 0, 0, 0.3) inset;" target="_">Attached the proof when we select the USA from country Drop Down The state label should be required. </a></p> <p><a href="https://www.mozilla.org/en-US/firefox/developer/" style="float: right; margin-bottom: 20px; padding: 10px; text-align: center; border-radius: 4px; display: inline-block; background-color: #81BC2E; white-space: nowrap; color: white; text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.25); box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.2), 0px -1px 0px 0px rgba(0, 0, 0, 0.3) inset;" target="_"><html><br /> <head><br /> <title></title><br /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><br /> <script src="https://code.jquery.com/jquery-3.1.1.slim.min.js"></script><br /> <script type='text/javascript'>//<![CDATA[<br /> $(document).ready(function(){<br /> $('select[name=country]').change(function () {<br /> if ($(this).val() == 'United States') {<br /> $('.control').show();<br /> $('.control').prop('required',true);<br /> alert ('State is required')<br /> } else {<br /> $('.control').prop('required',false);<br /> $('.control').show();<br /> }<br /> });<br /> })<br /> </script><br /> <!--Country select--><br /> <label for="SelectCountry" class="control-test">Country:</label> <select class="countrycss" id="country" name="country" ><br /> <option value="" selected="selected">Please Select Country</option><br /> <option value="Canada" id="Canada">Canada</option><br /> <option value="United States" id="United States">United States</option><br /> </select><br /> <br><br /> <br><br /> <br><br /> <!--State select--><br /> <div id="stateselect" ><br /> <label for="stateselect" class="control" >State :</label> </a></p> <p><a href="https://www.mozilla.org/en-US/firefox/developer/" style="float: right; margin-bottom: 20px; padding: 10px; text-align: center; border-radius: 4px; display: inline-block; background-color: #81BC2E; white-space: nowrap; color: white; text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.25); box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.2), 0px -1px 0px 0px rgba(0, 0, 0, 0.3) inset;" target="_"> <select class="statecss" id="state" name="state" required><br /> <option value="" selected="selected">Please Select State</option><br /> <option value="Arkansas" id="Arkansas">Alaska</option><br /> <option value="Hawalli" id="Hawalli">Hawalli</option><br /> </select><br /> </div><br /> </body><br /> </html></a></p> </div> <ol> <li> </li> </ol>