onblur和onfocus时检查并验证(内联验证)输入字段。 [英] Check and Validate(inline validation) input field when onblur and onfocus.

查看:97
本文介绍了onblur和onfocus时检查并验证(内联验证)输入字段。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用onblur和onfoucus,基本上我想使用内联验证消息。

< input name =emailaddresstype =textvalue =Fill
$ b $bönFocus=clearText(this)önBlur=clearText(this)>







我想要使用此链接注册页面的相同功能。



链接在这里.....请点击

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

推荐答案

试试这个。 :)



try this. :)

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







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


这篇关于onblur和onfocus时检查并验证(内联验证)输入字段。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆