Validation Bootstrap Select - Loaded by AJAX -


i trying add validation bootstrap-select somehow validation doesn't work

enter image description here

first selecting main category other bootstrap select ,

sub category loading ajax expected...

<select name="code" class="form-control" id="code"> </select> 

js

<script type="text/javascript">   $('#code').on('change', function(e) {                 // revalidate date field               $('#createsubcode').formvalidation('revalidatefield', 'code');           }); </script> 

more

    <script type="text/javascript">   $(document).ready(function() {     $('#createsubcode')         .formvalidation({             framework: 'bootstrap',             icon: {                 valid: 'glyphicon glyphicon-ok',                 invalid: 'glyphicon glyphicon-remove',                 validating: 'glyphicon glyphicon-refresh'             },             fields: {                 title: {                     validators: {                         notempty: {                             message: 'the title required'                         }                     }                 },                 code: {                     validators: {                         notempty: {                             message: 'the code required'                         }                     }                 }             }         })  }); </script> 

so whenever select says code required! validation doesn't pass!

i found problem

ajax

from

$.each(data,function(index,subcateobj){       $('#code').append('<option>'+subcateobj+'</option>');     }); 

to

$.each(data,function(index,subcateobj){       $('#code').append('<option value='+subcateobj+'>'+subcateobj+'</option>');     }); 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -