Thread: hotmail alert
View Single Post
Old 05-10-2008, 07:05 AM   #2
ranjan
 
Join Date: Dec 2004
Posts: 405
Default

if the html looks like this:

Code:
<input id="email" type="text"><span id="msg"></span>
the following javascript would work

Code:
window.onload = function() { //when the document loads

  var $ = function (el) { //create a function to return an element by id

    return  document.getElementById(el); // return the element

  }

  $('email').onblur = function() { //when email field loses focus

    var emailAddress = $('email').value; // get whan the user typed in

    var emailProvider = emailAddress.split("@"); // split input 

    var emailProvider = emailProvider[1]; // get domain

    if(emailProvider == 'hotmail.com' || emailProvider == 'msn.com' || emailProvider == 'live.com') {

      $('msg').innerHTML = 'Put your message here'; // if hotmail or msn or live then alert the user

    }

  }

}
ranjan is offline   Reply With Quote