<form class="row g-3 auto-width" action="{{ route('rate-calculation-type.store')}}" method="post" enctype='multipart/form-data'>
    @csrf
    @php $i=1;@endphp
    <div class="col-md-12">
        <label for="name" class="form-label">Name <span class="text-danger"><b>*</b></span></label>
        <input type="text" class="form-control" id="name" name="name" aria-describedby="inputGroupPrepend" required>
        <span class="text-danger error_name" style="display:none;">This field is required.</span>
    </div>
    <div class="col-md-6">
        <label for="code" class="form-label">Code <span class="text-danger"><b>*</b></span></label>
        <input type="text" class="form-control" id="code" name="code" aria-describedby="inputGroupPrepend" required>
        <span class="text-danger error_code" style="display:none;">This field is required.</span>
    </div>
    <div class="col-md-6">
        <label for="priority" class="form-label">Priority</label>
        <input type="text" class="form-control" id="priority" name="priority" aria-describedby="inputGroupPrepend" required value="{!! $priority + 1 !!}">
        <span class="text-danger error_priority" style="display:none;">This field is required.</span>
    </div>
    <div class="col-md-6">
        <div>
             <label for="is_volumetric" class="form-label">Is Volumetric</label>
        </div>
        <div class="input-group ">
            <select class="form-control is_volumetric" name="is_volumetric" >
                <option value="No">No</option>
                <option value="Yes">Yes</option>
            </select>
        </div>
    </div>
        <div class="col-md-6 yes_fields" style="display:none">
        <label for="divide_by" class="form-label">Divide By <span class="text-danger"><b>*</b></span></label>
        <input type="number" class="form-control" id="divide_by" name="divide_by" aria-describedby="inputGroupPrepend" required>
        <span class="text-danger error_divide_by" style="display:none;">This field is required.</span>
    </div>
    <div class="col-md-6 yes_fields"  style="display:none">
        <label for="round_up" class="form-label">Round Up </label>
        <input type="text" class="form-control" id="round_up" name="round_up" aria-describedby="inputGroupPrepend" required>
        <span class="text-danger error_round_up" style="display:none;">This field is required.</span>
    </div>
</form>
<script type="text/javascript">
      $("#priority").on('input', function() {
          const onlyNumbers = $(this).val().replace(/[^0-9]/g, '');
          $("#priority").val(onlyNumbers);
      });
      $(document).ready(function(){
        $('.is_volumetric').on('change',function(){
        var decision = ($('.is_volumetric').val());
        
        if($('.is_volumetric').val() == 'Yes') {
            $('.yes_fields').show();    
        }
        else if ($('.is_volumetric').val()  == 'No') {
            $('.yes_fields').hide();
        }
        })
        })
</script>