首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >LiveCycle Javascript函数ReferenceError

LiveCycle Javascript函数ReferenceError
EN

Stack Overflow用户
提问于 2013-06-22 01:39:04
回答 1查看 887关注 0票数 0

我不知道这个livecycle检查电子邮件地址的函数做错了什么。Livecycle控制台返回"ReferenceError: emailAddress未定义“的错误,即使该函数将触发警报或xfa.host.messageBox。你能告诉我为什么在运行完这个函数后不能定义全局变量emailAddress吗?耽误您时间,实在对不起。

代码语言:javascript
复制
function fxemailverification(emailAddress) {

    var r = new RegExp("^[A-Za-z0-9_\\-\\.]+\\@test.com");

    // Test the rawValue of the current object to see if it matches the new RegExp
    var result = r.test(emailAddress); 

    if (result == false) {
        var emailAddress = "";
        alert("You have entered an invalid Email address. \nAll email addresses must end in '@test.com'.", "Email Verification", 4, 0);
    }
    return emailAddress;
};

textfield1.rawValue = fxemailverification(emailAddress);
EN

回答 1

Stack Overflow用户

发布于 2013-06-22 01:41:59

emailAddress变量只存在于函数内部,但您试图从外部访问它。它超出了范围。不知道你在找什么,也许是这个?

代码语言:javascript
复制
var emailAddress = "";
function fxemailverification(emailAddress) {
    var r = new RegExp("^[A-Za-z0-9_\\-\\.]+\\@test.com");
    // Test the rawValue of the current object to see if it matches the new RegExp
    var result = r.test(emailAddress); 

    if (result == false) {
        emailAddress = "";
        alert("You have entered an invalid Email address. \nAll email addresses must end in '@test.com'.", "Email Verification", 4, 0);
    }
    return emailAddress;
};

textfield1.rawValue = fxemailverification(emailAddress);
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17241224

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档