Home > front end >  How to write the beginners, bosses solutions, learn from the answer
How to write the beginners, bosses solutions, learn from the answer

Time:09-16

From the text box input an email, to extract the user name, show the "* * * hello,"

CodePudding user response:

https://blog.csdn.net/l_ppp/article/details/106557211
Use regular expressions to extract, extract the article in my email address and user name code case, you can have a look

CodePudding user response:

 



<meta charset="utf-8" & gt;
<meta name="viewport" content="width=device - width, initial - scale=1.0" & gt;


<body>




<script>
Let p=document. QuerySelector (' p ')
Let z=null
Document. QuerySelector (' input '). The addEventListener (' input, e=& gt; {
Let the dom=e. arget
ClearTimeout (z)
If (/^ + @ \ w + \ [a - z0-9], [a-z] {2, 4} $/. The test (dom) value)) {
Let the index=dom. Value. IndexOf (' @ ')
Let the text=dom. Value. The substring (0, index)
P.t extContent=${text} ` hello `
} else {
Z=setTimeout (()=& gt; {
P.t extContent='you entered is not correct mailbox'
}, 500)
}
})
</script>

CodePudding user response:

reference 2 floor to lotus response:
 



<meta charset="utf-8" & gt;
<meta name="viewport" content="width=device - width, initial - scale=1.0" & gt;


<body>




<script>
Let p=document. QuerySelector (' p ')
Let z=null
Document. QuerySelector (' input '). The addEventListener (' input, e=& gt; {
Let the dom=e. arget
ClearTimeout (z)
If (/^ + @ \ w + \ [a - z0-9], [a-z] {2, 4} $/. The test (dom) value)) {
Let the index=dom. Value. IndexOf (' @ ')
Let the text=dom. Value. The substring (0, index)
P.t extContent=${text} ` hello `
} else {
Z=setTimeout (()=& gt; {
P.t extContent='you entered is not correct mailbox'
}, 500)
}
})
</script>

Thank you for big help
  • Related