在knockout js中验证电子邮件时调用自定义函数

发布于 2025-01-14 08:03:30 字数 467 浏览 2 评论 0原文

我正在使用knockout js验证电子邮件并通过错误,而如果电子邮件同时无效,我想调用函数调用我试图做类似的事情但不起作用请有人帮助我知道执行此操作的确切方法

 email: ko.observable((ref = REGISTRY.unsavedUser) != null ? ref.email : void 0).extend({
    required: true,
    email: {
      params: true,
      message: 'Please enter a valid emails.',
    },
    validation: {
        validator: testFuc
    },
    focus:true
  }),

,testFuc是作为

var testFun = function() {
  alert();

}

i am validating email with knockout js and throughing error while if email not valid on the same time i want to invoke a fuction call iam trying to do somthing like that but not working please someone help i know the exact way to do that

 email: ko.observable((ref = REGISTRY.unsavedUser) != null ? ref.email : void 0).extend({
    required: true,
    email: {
      params: true,
      message: 'Please enter a valid emails.',
    },
    validation: {
        validator: testFuc
    },
    focus:true
  }),

and testFuc is as

var testFun = function() {
  alert();

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ゃ懵逼小萝莉 2025-01-21 08:03:30
  validator: testFuc

与函数名称 testFun 不匹配

还要确保您的函数是在敲除脚本之前定义的

  validator: testFuc

does not match the function name testFun

also make sure your function is defined before your knockout script

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文