victorjonsson / jQuery-Form-Validator

[DISCONTINUED] jQuery plugin that makes it easy to validate user input while keeping your HTML markup clean from javascript code.
972 stars 476 forks source link

Cannot use the security and file validation #619

Closed harishdurga closed 7 years ago

harishdurga commented 7 years ago

Hello, sir. First of all this is the best validation plugins of all Jquery plugins available. Really it helped me to avoid writing custom js code for regular validations. But recently i am trying to use the file and security related validations. Whenever i try to load the security module i am getting errors. screenshot_20170724_105529 screenshot_20170724_110417

html: <input type="text" name="std_username" id="std_username" class="form-control" placeholder="username" data-validation="required custom server" data-validation-regexp="^[a-zA-Z0-9]*$" data-validation-url="<?=base_url('/isUsernameValid')?>"> Script:

  $.validate({
    modules:'security'
  });
victorjonsson commented 7 years ago

It looks as if the module files gets loaded before the main script file. Are you using some sort of build tools such as browserify or meteor?

harishdurga commented 7 years ago

No sir, I am not using any of those tools. Here is the complete script.

<script type="text/javascript" src="<?php echo base_url('assets/jquery.js'); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('assets/bootstrap/bootstrap.min.js'); ?>"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/jquery-form-validator/2.3.26/jquery.form-validator.min.js"></script>
    <script type="text/javascript">
        $.validate({
            modules:'security'
        });
    </script>
victorjonsson commented 7 years ago

Well I'm not able to reproduce this: http://jsbin.com/jazebaroxe/edit?html,console,output

The error message is truly strange. The first two messages implies that the module files gets loaded before the main script. The last error message gets thrown when validation is triggered and the attribute data-validation contains a validation rule that is not loaded. This error message implies the opposite of the first two, that the main script is loaded but no module files.

It's hard for me to give you any advise. You must look, in deep detail, at the generated source code of your website.

harishdurga commented 7 years ago

Ok,thanks for responding. I will once look deep into my code. I will ask you if I cannot understand some aspect or error message from the plugin.

harishdurga commented 7 years ago

Hello, I found the issue. It is due to the multiple script tags in my code for importing jquery. Now, the security validation is working. Thanks for the awesome plugin.