gpt4 book ai didi

javascript - 表单验证在 Visualforce 中不起作用,但在 html 中起作用

转载 作者:行者123 更新时间:2023-11-28 07:31:59 24 4
gpt4 key购买 nike

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

        <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.js 之后的 HEAD 部分

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

关于javascript - 表单验证在 Visualforce 中不起作用,但在 html 中起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29030482/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com