简体   繁体   English

UI5的输入字段中有多封电子邮件

[英]multiple emails in an input field in UI5

I have a use case where I want to add multiple email addresses in the sap.m.Input field. 我有一个用例,我想在sap.m.Input字段中添加多个电子邮件地址。 Is there any way I can do it with keeping type sap.m.InputType.Email of the input field? 我有什么办法可以保持输入字段的类型sap.m.InputType.Email

I have checked that in HTML5, <input> tag has multiple attribute which allows user to enter multiple values of the given input-type. 我检查了HTML5中的<input>标记是否具有multiple属性,该属性允许用户输入给定输入类型的多个值。 I want similar thing here. 我在这里想要类似的东西。

I want to validate all the email addresses also. 我也想验证所有电子邮件地址。 So currently I am doing it by splitting the email addresses from the sap.m.Input value by semicolons and manually validating each email address from the sap.m.Input 's email validator. 因此,目前,我是通过用分号将sap.m.Input值中的电子邮件地址sap.m.Input并手动验证sap.m.Input的电子邮件验证器中的每个电子邮件地址来实现的。

var oEmails = new sap.m.Input();

onFormSubmit: function(oEmail) {
    var isValidEmails = false;
    var emails = oEmail.getValue().split(";");
    for (var i=0; i<emails.length; i++) {
        var emailValidation = oEmail.getValidator().emailValidation(emails[i]);
        var isInvalidEmail = (emailValidation.valueType === "Error");
        if (isInvalidEmail) {
            showError(oEmail);
            isValidEmails = false;
            break;
        } else {
            isValidEmails = true;
        }
    }
    return isValidEmails;
}

I haven't added type of Input in the oEmails as it return an error for multiple emails. 我没有在oEmails添加Input类型,因为它会为多封电子邮件返回错误。 But I want to use it so Input control should take care of the validation. 但是我想使用它,因此输入控件应注意验证。 Is there any better approach to deal with these problem? 有没有更好的方法来解决这些问题?

Thanks in advance. 提前致谢。

Have you looked at sap.m.MultiInput ? 你看过sap.m.MultiInput吗? It uses tokens for the individual entries but semantically it offers you to enter multiple entries and you can set the type to email, although I have not tried it so far. 它为单个条目使用令牌,但从语义上讲,它使您可以输入多个条目,并且可以将类型设置为电子邮件,尽管到目前为止我还没有尝试过。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM