问题描述
这是表单嵌入代码。
<script>
hbspt.forms.create({
portalId: "XXXXXXX",formId: "XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",translations: {
en: {
required: " ",missingSelect: " "
}
},onFormReady: function() {
let fpwd = document.getElementById("set_password");
if (fpwd.type !== "password") {
fpwd.type = "password";
}
let fpwd2 = document.getElementById("confirm_password");
if (fpwd2.type !== "password") {
fpwd2.type = "password";
}
var email = $("#email-e1a8a5cf-09b6-45b9-9ae1-f73aa13e0ef1").val();
$.validator.addMethod(
"uniqueEmail",function(value,element) {
$.ajax({
url: 'https://xxx.xxxxxx.com/rest/v1/portal/usertrial/' + email,type: "POST",cache: true,async: true,headers: {
'Content-Type': 'application/json','XXXXHeader_1': 'Yes','x-access-token': 'xxxFromWebsite'
},success: function(msg)
{
//If email exists,set response to true
response = ( msg == 'true' ) ? true : false;
}
});
return response;
},"Email is already taken"
);
$('#hsForm').validate({
rules: {
firstname: "required",lastname: "required",phone: "required",company: "required",set_password: {
minlength : 8
},confirm_password : {
minlength : 8,equalTo : "#set_password"
},email: {
required: true,uniqueEmail: true
},i_am: "required"
},messages: {
email: {
required: "Valid email required",uniqueEmail: "Email is taken already"
}
}
});
}
});
</script>
我的电子邮件字段有问题,有时我会收到“电子邮件已被占用”消息,但表单仍会提交。
第二个问题是,如果我在不提交电子邮件的情况下更改了电子邮件,则会出现此错误
jquery.validate.js:825 Uncaught ReferenceError: response is not defined
at $.validator.<anonymous> (remote-support-software:634)
at $.validator.check (jquery.validate.js:798)
at $.validator.element (jquery.validate.js:509)
at $.validator.onfocusout (jquery.validate.js:309)
at HTMLInputElement.delegate (jquery.validate.js:440)
at HTMLFormElement.dispatch (app.js:1)
at HTMLFormElement.g.handle (app.js:1)
at Object.trigger (app.js:1)
at Object.simulate (app.js:1)
at HTMLDocument.n (app.js:1)
请帮忙。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)