Click here to Skip to main content
15,897,226 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am using onblur and onfoucus but i am do't know apply java script code.
<input name="emailaddress" type="text" value="Fill"
onFocus="clearText(this)" önBlur="clearText(this)">

I want to same functionality ,which is using this link site below
link here.....please click and check
Posted
Updated 24-May-14 3:19am
v3
Comments
[no name] 24-May-14 9:02am    
http://www.w3schools.com/js/DEFAULT.asp

1 solution

try this.. :)

HTML
<div>
      Email:
      <input type="text" name="email" id="txtEmail" onblur="validateForm()">
      <label id="lblError" style="color:red"></label>
  </div>


Javascript
JavaScript
function validateForm() {
         var x = document.getElementById("txtEmail").value;
         var atpos = x.indexOf("@");
         var dotpos = x.lastIndexOf(".");
         if (atpos < 1 || dotpos < atpos + 2 || dotpos + 2 >= x.length) {


             document.getElementById("lblError").innerHTML = "Enter valid email Address";
         }
         else {
             document.getElementById("lblError").innerHTML = "";
         }
     }


You can call same function onfocus also.. :)
 
Share this answer
 
v3
Comments
amanpavanker 24-May-14 9:24am    
thank sir but i want to alert show on inline validation.
Nirav Prabtani 24-May-14 9:43am    
try updated solution and mark it as solved if it helps you .. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900