How to remove extra space in mobile mode

时间:2017-12-18 06:06:50

标签: c# android razor

Am using razor textbox to get email id , in mobile mode while typing the email address, if i select the auto-suggest of full email then at end its adding extra space. how to get rid of this.

(Note: - Am using validation too, so i cant trim the textbox text on blur. i tried this too no luck)

<div class="col-md-3">
    <label>Email</label><label class="requiredfields"> *</label>
    <p>
        @Html.TextBoxFor(model => model.SignatureModel.Email, new { @class = "form-control", @onblur = "return onemailblur()" } )
        @Html.ValidationMessageFor(model => model.SignatureModel.Email)
    </p>
</div>

1 个答案:

答案 0 :(得分:0)

我找到了一个解决方案,我改变了正则表达式以允许多个空格结束,我修改了getset访问器上的电子邮件文本。

[RegularExpression("^[a-zA-Z0-9_\\.-]+@([a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,6} *$", ErrorMessage = "E-mail is not valid")]
        public string Email
        {
            get { return _email; }
            set
            {
                _email = value.Trim();
            }
        }