Click here to Skip to main content
15,894,646 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am using onblur and onfoucus ,basically i want to use inline validation message.
<input name="emailaddress" type="text" value="Fill"
önFocus="clearText(this)" önBlur="clearText(this)">



I want to same functionality ,which is using this link registration page.

link here.....please click
Posted
Updated 24-May-14 3:45am
v2
Comments
Nirav Prabtani 24-May-14 9:46am    
Please don't post same question more than one time

1 solution

try this. :)

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 = "";
          }
      }


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

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