javascript - assign value to select box ( form validation ) -


i creating form validation, , have fields working great. trickyness seems arise parsing value select box

i know how assign value within form element, have:

<select id="sms" name="sms" class="medium">                                  <optgroup label="sms alerts">                                   <option value="">please choose</option>                                   <option value="1">yes</option>                                   <option value="0">no</option>                                 </optgroup>                             </select> 

but not sure within js select box.

currently field have:

$("#mobile").blur(function() {          if(validate_form_field($(this), $(this).val().length>9)) {             mobile_passed = true;         } else {             mobile_passed = false;         }     }); 

essentially, want validate value =1 select box. do ?

$("#sms").blur(function() {          if(validate_form_field($(this), $(this).val().length=1)) {             sms_passed = true;         } else {             sms_passed = false;         }     }); 

cheers ste

added info:

the form propagate progress bar.

so here portion of script, split 3 main parts within js. have included field , select box, see goin wrong.

var mobile_passed = false; var sms_passed = false;  $("#mobile").blur(function() {          if(validate_form_field($(this), $(this).val().length>9)) {             mobile_passed = true;         } else {             mobile_passed = false;         }     });      $("#sms").blur(function() {          if(validate_form_field($(this), $(this).val().length=1)) {             sms_passed = true;         } else {             sms_passed = false;         }     });  var $object_mobile = $("#mobile");     no_errors = validate_form_field($object_mobile, $object_mobile.val().length>9);      var $object_sms = $("#sms");     no_errors = validate_form_field($object_sms, $object_sms.val().length=1); 

plan b

what if ditch select box idea, , add input field know these work. validate if user types yes

how achieve ??

$("#sms").blur(function() {      if(validate_form_field($('#sms option:selected').val()), $('#sms option:selected').val().length=1)) {         sms_passed = true;     } else {         sms_passed = false;     } }); 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -