0

finding difficulties in result. unable to retrieve email part and domain partof the mail id.

<!DOCTYPE html> <html> <head> <title>indexing</title> <script type="text/javascript"> function getEmailAndDomainParts() var emailAddress = document.getElementById("myemail").value; var emailPart = emailAddress.substring(0, emailAddress.indexOf("@")); var domainPart= emailAddress.substring(emailAddress.indexOf("@")); document.getElementById("emailparty").value = emailPart; document.getElementById("domainpartx").value = domainPart; </script> </head> <body> <form> <table style="border: 1px solid black; font-family: Arial"> <tr> <td> email adress </td> <td> <label></label> <input type="text"; id="myemail"; value="enter email id"/><br> </td> </tr> <tr> <td> email part </td> <td> <label> </label> <input type="text"; name="emailparty"; id="mailpa"><br> </td> </tr> <tr> <td>domian part</td> <td> <label></label> <input type="text"; id="domainpartx"; value=""/><br> </td> </tr> <tr> <td> </td> <td> <input type="button"; onclick="getEmailAndDomainParts()" value="get email and domain part" ; style="width: 200px" background-color="red";> </td> </tr> </table> </form> </body> </html>

25th Jul 2020, 6:34 AM
Avinash
2 Answers
+ 1
1. Wrap the body of getEmailAndDomainParts function with curly brackets function getEmailAndDomainParts() { // code here } 2. Use email input for myemail element. <input type="email" id="myemail /> 3. Set ID for e-mail part to "emailparty". Current ID for that element is now "mailpa". JS cannot refer that element because your script uses "emailparty" as ID of element to refer to. 4. Save that code and share the link instead. People had to copy/paste it every time before they can check the code, it's a hassle. Follow below guide to share code link. https://www.sololearn.com/post/75089/?ref=app
25th Jul 2020, 4:39 PM
Ipang
+ 1
Big big thank you. Amazing ...
25th Jul 2020, 5:10 PM
Avinash