Suhas Bhattu
Suhas Bhattu

Reputation: 551

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. Is there any way I can do it with keeping type sap.m.InputType.Email of the input field?

I have checked that in HTML5, <input> tag has multiple attribute which allows user to enter multiple values of the given input-type. 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.

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. 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.

Upvotes: 0

Views: 1044

Answers (1)

pguddi
pguddi

Reputation: 345

Have you looked at 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.

Upvotes: 2

Related Questions