SQL PHP HTML ASP JavaScript articles and free scripts to download
JavaScript Tutorials
Popular Tutorials
Drop down list
Timer function
JavaScript Tutorials
String
Array
Date & Time
Form Validation
Event Handling
Math Functions
JavaScript Forum
Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.

 
 

Domain name and userid of email address

We can collect userid and domain name part of any email address by using JavaScript string function slice and indexOf. We will use indexOf function to find the location of @ symbol ( or char ) present inside the email address. Using this value we will slice the string starting from left side 0 position to collect the userid part of the email address. Here is the code.




var my_email="useridhere@sitename.com"
var ind=my_email.indexOf("@");
var my_slice=my_email.slice(0,ind);
document.write(my_slice);

Now how to collect the domain part from the email address? We will use the string.length to find out the total length of the string and then collect the part of the string starting from the location of (@ +1) till the end of the string. Here is the code.

var my_email="useridhere@sitename.com"
var ind=my_email.indexOf("@");
var my_slice=my_email.slice((ind+1),my_email.length);
document.write(my_slice);
Read how domain name and user id is separated from email address by using PHP
Further readings
Lower case text to Uppercase text
Uppercase letter to Lower case
Bold text letters using JavaScript
String Length
Character at a location using charat function
Indexof function
String Reverse function
search():Searching String inside another string
slice():Collecting part of a string using slice function
Domain and userid part of email address
Text box onBlur click event changing text case
 
Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.

Scripts
PHP
JavaScript