表单验证在 HTML 中工作的 Visualforce 中不起作用



表单验证不起作用,但相同的代码在 HTML 中运行,表单验证也有效,我已经上传了所有静态资源,请告诉我需要对代码进行哪些更改。1. 我已成功上传静态资源。2. 所有文件路径正确。3.建议我是否对html标签进行任何必要的更改

        <apex:stylesheet value="{!URLFOR($Resource.validation, 'valid/bootstrap.min.css')}"/>
        <apex:stylesheet value="{!URLFOR($Resource.validation, 'valid/formValidation.min.css')}"/>
        <apex:includeScript value="{!URLFOR($Resource.validation,'valid/bootstrap.min.js')}"/>
        <apex:includeScript value="{!$Resource.bootstrapjs}"/>
        <apex:includeScript value="{!URLFOR($Resource.validation,'valid/bootstrap1.min.js')}"/>
        <apex:includeScript value="{!URLFOR($Resource.validation,'valid/formValidation.min.js')}"/>
        <apex:includeScript value="{!URLFOR($Resource.validation,'valid/jquery.min.js')}"/>

    </head>
    <body>
        <form id="basicBootstrapForm" class="form-horizontal">
            <div class="form-group">
                <label class="col-xs-3 control-label">Full name</label>
                <div class="col-xs-4">
                    <input type="text" class="form-control" name="firstName" placeholder="First name" />
                </div>
                                </div>

                                   </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-3 control-label" id="captchaOperation"></label>
                <div class="col-xs-4">
                    <input type="text" class="form-control" name="captcha" />
                </div>
            </div>

            <div class="form-group">
                <div class="col-xs-9 col-xs-offset-3">
                    <button type="submit" class="btn btn-primary" name="signup" value="Sign up">Submit</button>
                </div>
            </div>
        </form>
        <script>
        $(document).ready(function() {
            // Generate a simple captcha
            function randomNumber(min, max) {
                return Math.floor(Math.random() * (max - min + 1) + min);
            }
            $('#captchaOperation').html([randomNumber(1, 100), '+', randomNumber(1, 200), '='].join(' '));
            $('#basicBootstrapForm').formValidation({
                framework: 'bootstrap',
                icon: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
                    firstName: {
                        row: '.col-xs-4',
                        validators: {
                            notEmpty: {
                                message: 'The first name is required'
                            }
                        }
                    },
                 }   
            });
        });
        </script>
    </body>
</html>

这是一个

奇怪的问题。当使用CDN时,它会得到解决,就像下面在Jquery之后的HEAD部分一样.js

<script src="https://cdn.jsdelivr.net/npm/jquery-validation@1.17.0/dist/jquery.validate.min.js"></script>

相关内容

  • 没有找到相关文章

最新更新