i trying onfocus , onblur events. it's not working. when click email field value not disappears. here's code. please tell me if there's wrong.
<!doctype html> <html> <head> <title>more events</title> </head> <body> <form> <input type="text" value="your email" name="email" id="email" /> </form> <script> var emailfield = document.getelementbyid('email'); emailfield.onfocus = function(c) { if (emailfield.value == 'your email') { emailfield.value == ''; } } emailfield.onblur = function(c) { if (emailfield.value == '') { emailfield.value == 'your email'; } } </script> </body> </html>
you using comparison operator(==
) instead of assignment operator(=
) here:
emailfield.value == '';
change to
emailfield.value = '';
in code:
var emailfield = document.getelementbyid('email'); emailfield.onfocus = function(c) { if (emailfield.value == 'your email') { emailfield.value = ''; } } emailfield.onblur = function(c) { if (emailfield.value == '') { emailfield.value = 'your email';//also here } }
Comments
Post a Comment