3

I know there are many question on this topic but my question is a bit different

when ever I try to submit a form using jquery I getting below error.

SyntaxError: expected expression, got ')'

void()

enter image description here

here is my html

<form accept-charset="utf-8" method="post" id="UserIndexForm" data-togglesd="validator" role="form" class="specialist_filter_form validatate_form fv-form fv-form-bootstrap" action="/example/specialist" novalidate="novalidate"><button type="submit" class="fv-hidden-submit disabled" style="display: none; width: 0px; height: 0px;" disabled="disabled"></button><div style="display:none;"><input type="hidden" value="POST" name="_method"></div>
    <section class="view_section inner_view">
        <div class="container ph0">
            <aside class="col-md-3">
                <div class="filter_side">
                    <h6 class="bg_blue tab_heading ac">Refine Your Result</h6>
                    <div class="filter_box p20">
                        <label>Specialization <a class="pull-right" href="#" data-target="#specialist_selectbox" data-toggle="modal"><i class="fa fa-plus"></i></a></label>
                        <ul class="selected_tag"></ul>             
                    </div>
                    <div class="filter_box p20">
                        <label>Search By Name</label>
                        <div class="form-group mt10 search-query-input has-success">
                            <input type="text" id="UserKeywords" data-fv-regexp-message="The name can consist of alphabetical characters and spaces only" data-fv-regexp-regexp="^[a-z\s]+$" data-fv-regexp="true" data-fv-notempty-message="This field cannot be left blank." required="required" class="form-control searchKeywords ui-autocomplete-input" name="data[User][keywords]" data-fv-field="data[User][keywords]" autocomplete="off">                        <!--                        <a href="javascript:void()" class="search-query" onclick="document.getElementById('UserIndexForm').submit(); return false;">
                                                        <i class="fa fa-search"></i><div class="ripple-wrapper"></div>
                                                    </a>-->
                            <a id="your-id" class="search-query" href="javascript:void()">
                                <i class="fa fa-search"></i><div class="ripple-wrapper"></div>
                            </a>
                            <input type="hidden" id="UserId" name="data[User][id]">
                            <small style="display: none;" class="help-block" data-fv-validator="notEmpty" data-fv-for="data[User][keywords]" data-fv-result="VALID">This field cannot be left blank.</small>
                            <small style="display: none;" class="help-block" data-fv-validator="regexp" data-fv-for="data[User][keywords]" data-fv-result="VALID">The name can consist of alphabetical characters and spaces only</small></div>
                    </div>
                </div>
            </aside>


        </div>
    </section>


</form>

and here is the JS

$("#your-id").click(function () {
   if (!$("#UserKeywords").val()) {
      $('.search-query-input').addClass('has-error');
      $(".help-block").first().show();
      return false;
   } else {
      console.log($("#UserKeywords").val());
      $("#UserIndexForm").submit();
      //return true;
   }
});
urfusion
  • 5,528
  • 5
  • 50
  • 87

1 Answers1

4

Void expects a parameter, as described here: JavaScript : void operator

Use this:

  <a href="javascript:void(0)" class="search-query" onclick="document.getElementById('UserIndexForm').submit(); return false;">
  </a>
DirtyBit
  • 16,613
  • 4
  • 34
  • 55