Product Feedback users always enter the wrong email domain name, so the email address obtained by the server is incorrect. For example, there are many users who always input a xxx@qq.com into a xxx@qq.con.
This worries the backend, because the email address is legal, but the error is so obvious (I do not know whether the QQ. Con domain name exists ).
To solve this problem, I spent an hour in the afternoon using the new list attribute in HTML5 input. When the user inputs '@', the user is prompted with Domain Name Information. :
However, it was found that this property was not supported in Safari, and thus could not be supported in the app. It is estimated that it can only be used in chrome. It's just learning. The general idea is to listen to the user input '@', construct a datalist, and associate it with the input. Dependent on jquery.
(Function () {var emails = [{domain: '@ QQ.com', label: 'qq mailbox '}, {domain:' @ 163.com ', label: 'mailbox 163 '}, {domain:' @ 126.com ', label: 'mailbox 126'}, {domain: '@ hotmail.com', label: 'hotmail '}, {domain: '@ Sina.com', label: 'sina '}, {domain:' @ gmail.com ', label: 'gmail '}, {domain: '@ 139.com ', label: '2014 mailbox '}, {domain:' @ yahoo.com.cn ', label: 'yahoo China mailbox'}]; var addemailhelp = function (ID, otheraddress) {var I Nputobj = $ ('input # '+ id); If (inputobj. length = 0) {return;} inputobj. keyup (function (EV) {var val = $ (inputobj ). val (); var lastinputkey = Val. charat (Val. length-1); If (lastinputkey = '@') {var indexofat = Val. indexof ('@'); var username = Val. substring (0, indexofat); if ($ ('datalist # emaillist '). length> 0) {$ ('datalist # emaillist '). remove () ;}$ (inputobj ). parent (). append ('<datalist id = "EMA Illist "> </datalist> '); For (var I in emails) {$ ('datalist # emaillist '). append ('<option value = "' + username + emails [I]. domain + '"label ="' + emails [I]. label + '"/>');} If (otheraddress! = NULL & typeof otheraddress! = 'Undefined') {for (var I in otheraddress) {$ ('datalist # emaillist '). append ('<option value = "' + username + otheraddress [I]. domain + '"label ="' + otheraddress [I]. label + '"/>') ;}$ (inputobj ). ATTR ('LIST', 'emaillist') ;}}; window. addemailhelp = addemailhelp ;})();
You can set an ID for input and associate it with addemailhelp (ID, otheraddress). This function is already associated with some frequently used mailbox domain names by default.
Otheradress can be associated with other custom addresses. This parameter can be blank when a function is called.
An otheraddress instance: [{domain: '@ xxx.com', label: 'xxx mailbox '}, {domain:' @ yyy.com ', label: 'yyy mailbox'}].
A complete call instance: