久久久久久久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問題)
主站蜘蛛池模板: 91精品国产91久久久久久最新 | 久久久久久九九九九九九 | 久久精品 | 天天操狠狠操 | 国产精品久久久久久久久久久免费看 | 亚洲国产一区在线 | 91超碰caoporn97人人 | 日韩欧美视频网站 | 欧美影院 | 国产在线观看不卡一区二区三区 | 国产精品欧美一区二区三区 | 国产精品视频一区二区三区四蜜臂 | 在线免费观看欧美 | 成人综合在线视频 | 在线观看中文字幕 | 国产精品国产成人国产三级 | 一区二区国产在线观看 | 伊人久久免费视频 | 天天插天天射天天干 | 久久国产高清 | 免费色网址 | 超碰最新在线 | 日韩欧美在线一区 | 91av在线免费观看 | 国产中文视频 | 日韩一级免费看 | 久久精品国产一区二区电影 | 中文字幕一区二区三区四区 | 男女在线免费观看 | 国产精品国产三级国产播12软件 | 国产福利在线视频 | 羞羞色网站| 国产一级毛片精品完整视频版 | 欧美1级 | 中文字幕亚洲精品 | 国产欧美一区二区三区国产幕精品 | 99久久婷婷国产亚洲终合精品 | 日韩免费av一区二区 | 精品毛片在线观看 | 日韩欧美三区 | 日韩精品二区 |