久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

驗證 EditText 中的電子郵件

Validate an email inside an EditText(驗證 EditText 中的電子郵件)
本文介紹了驗證 EditText 中的電子郵件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我想驗證在 EditText 中引入的電子郵件以及我已經擁有的代碼:

I want to validate an email introduced inside an EditText and this the code that I already have:

最終的 EditText textMessage = (EditText)findViewById(R.id.textMessage);

final EditText textMessage = (EditText)findViewById(R.id.textMessage);

最終 TextView 文本 = (TextView)findViewById(R.id.text);

final TextView text = (TextView)findViewById(R.id.text);

    textMessage.addTextChangedListener(new TextWatcher() { 
        public void afterTextChanged(Editable s) { 
            if (textMessage.getText().toString().matches("[a-zA-Z0-9._-]+@[a-z]+.[a-z]+") && s.length() > 0)
            {
                text.setText("valid email");
            }
            else
            {
                text.setText("invalid email");
            }
        } 
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {} 
        public void onTextChanged(CharSequence s, int start, int before, int count) {} 
    }); 

問題是,當我在@"之后引入 3 個字符時,它會出現消息有效電子郵件",而當我引入完整的電子郵件時它必須出現.

The problem is that when I introduce 3 characters after the "@", it appears the message "valid email", when it must appear when I introduce the complete email.

有什么建議嗎?

謝謝大家!

推薦答案

只要改變你的正則表達式如下:

Just change your regular expression as follows:

"[a-zA-Z0-9._-]+@[a-z]+\.+[a-z]+"

因為 .(dot) 表示匹配任何單字符.在您的點之前添加一個雙反斜杠以代表一個真正的點.

Because . (dot) means match any single-char.ADD a double backslash before your dot to stand for a real dot.

這篇關于驗證 EditText 中的電子郵件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Cut, copy, paste in android(在android中剪切、復制、粘貼)
android EditText blends into background(android EditText 融入背景)
Change Line Color of EditText - Android(更改 EditText 的線條顏色 - Android)
EditText showing numbers with 2 decimals at all times(EditText 始終顯示帶 2 位小數的數字)
Changing where cursor starts in an expanded EditText(更改光標在展開的 EditText 中的開始位置)
EditText, adjustPan, ScrollView issue in android(android中的EditText,adjustPan,ScrollView問題)
主站蜘蛛池模板: 在线免费黄色小视频 | jav成人av免费播放 | 午夜视频在线免费观看 | 久久综合国产精品 | 午夜视频网站 | av国产精品 | 超碰人人在线 | 四虎影院新网址 | 国产一区视频在线 | 亚洲精品久久久蜜桃网站 | 成年人黄色小视频 | 91久色| 国产精品视频久久久久久 | 一级做受毛片免费大片 | 亚洲一区自拍 | 最新中文字幕第一页视频 | 拍拍无遮挡人做人爱视频免费观看 | 日本免费网 | 日韩欧美国产电影 | 成人三级网址 | 人人擦人人 | 在线综合视频 | 久久91| 欧美日韩国产高清 | 无吗视频| h视频在线免费观看 | 国产精品久久久久婷婷二区次 | 99国产精品久久久久久久 | 色综合久| 日本午夜在线视频 | 韩国精品一区二区三区 | 91亚洲免费 | 日韩激情免费 | 二区国产 | 在线欧美亚洲 | 国内精品一区二区 | 97精品超碰一区二区三区 | 美女网站视频免费黄 | 一区| 7777在线视频 | av夜夜操 |