表单验证(实时判断)

这篇博客介绍了如何实现提供更好用户体验的表单验证,通过实时判断用户输入数据的正确性,作为正则表达式应用的延伸。文章展示了具体的实现效果和相关代码,部分方法为首次使用,作者期待读者的反馈和建议。
摘要由CSDN通过智能技术生成

上次的正则版表单验证的主要用意是为了正则表达式的应用,而这次的表单验证提供的更加完善的用户体验(实时判断了用户的输入数据正确与否),它是上个版本的延伸。

实现效果:

相应代码:

<!DOCTYPE html>
<html lang="en">
<!-- 此表单虽然样式比较简单,但功能实现还是比较复杂的,不同于一般的一步性验证而是将分步验证和最终验证结合在一起
实现了在输入不同的数据时对数据的实时判断 -->
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>表单验证</title>
    <link rel="stylesheet" href="./css/iconfont.css">
    <!-- 字体图标的引入 -->
    <style>
        /* css样式  和之前的正则版表单验证一样,实际上这个是先前写的*/
        #formuser{
            display: block;
            margin: 0 auto;
            width: 400px;
        }
        .form_user>li{
            position: relative;
            list-style: none;
            height: 50px;
            width: 400px;
            border: 1px solid gray;
            border-radius: 5px;
            margin: 40px 0;
        }
        .form_user>li>input{
            width: 378px;
            height: 48px;
            border-style: none;
            outline: none;
            margin-left: 1px;
            padding-left: 20px;
            color: black;
            font-size: 20px;
        }
        .tel{
            position: relative;
            border-style: none !important;
        }
        .usertelnum{
            width: 150px;
            height: 50px;
            border: 1px solid grey;
            border-radius: 5px;
            line-height: 50px;
            position: relative;
            float: left;
        }
        .usertelnum>input{
            position: absolute;
            border-style: none;
            outline: none;
            top: 0px;
            left: 1px;
            width: 120px;
            height: 48px;
            padding-left: 20px;
            font-size: 20px;
        }
        #icon{
            position: absolute;
            top: 0;
            right: 10px;
            color: gray;
        }
        .show_phone{
            float: right;
            width: 210px !important;
            height: 50px !important;
            border-radius: 5px;
            border: 1px solid silver !important;
            font-size: 20px;
            padding-left: 20px;
 
  • 3
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值