javascript - jquery check if standard value is selected before submit in input? -


i have dropdown box created divs, possible check jquery if other "select domain" selected before submit, if not should not submitted.

<div class="customselectbox" id="customselectbox_1">             <input type="hidden" name="domainname" value="select domain" class="customselectbox_input">             <div class="customselectbox_text" style="width: 82px;">select domain</div>             <div class="customselectbox_array"></div>             <div class="customselectbox_values" style="visibility: hidden; width: 122px;">             <div class="customselectbox_valbox scroll-pane" style="overflow: hidden; padding: 0px; width: 122px;">              <div class="jspcontainer" style="width: 122px; height: 68px;"><div class="jsppane" style="padding: 0px; top: 0px; left: 0px; width: 122px;"><ul>                 <li data-value="domain1.dk">domain1.dk</li><li data-value="domain2.dk">domain2.dk</li>              </ul></div></div></div>             </div>         </div> 

i use button submit:

<button name="checkdomain" type="submit" id="checkdomain" value="submit" class="btn btn-small btn-testemail">check</button> 

and javascript check inputbox before submit:

<script> $('#checkdomain').click(function (e) {             var isvalid = true;             $('#name').each(function () {                 if ($.trim($(this).val()) == '') {                     isvalid = false;                     $(this).css({                         "border": "1px solid red",                         "background": "#ffcece"                     });                 }                 else {                     $(this).css({                         "border": "",                         "background": ""                     });                 }             });             if (isvalid == false)                 e.preventdefault();              }); </script> 

this jquery line should text

$('#customselectbox_1 .customselectbox_text').html(); 

so think should p.s not tested

$('#checkdomain').click(function (e) {             var isvalid = true;             $('#name').each(function () {                 if ($.trim($(this).val()) == '') {                     isvalid = false;                     $(this).css({                         "border": "1px solid red",                         "background": "#ffcece"                     });                 }                 else {                     $(this).css({                         "border": "",                         "background": ""                     });                 }             });              if ($('#customselectbox_1 .customselectbox_text').html() == 'select domain') { isvalid = false; }              if (isvalid == false)                 e.preventdefault();                 return false;              }); 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -