vuejs实现表单字段输入验证效果代码

代码语言:html

所属分类:验证

代码描述:vuejs实现表单字段输入验证效果代码,包含输入框、时间选择框、下拉选择框等控件。

代码标签: vue 表单 验证

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en">

<head>
    <title>Form Validation With VueJs</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/bootstrap.4.3.1.min.css">
    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/vue@2.6.1-dev.js"></script>
    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/vue-simple-search-dropdown.min.js"></script>
    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/vuejs-datepicker.js"></script>
     <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/vuejs-datepicker/locale/translations/zh.js"></script>
    

    <script type="text/javascript">
        Vue.use(Dropdown);
    </script>
</head>

<body>
    <div class="container" id="app">
        <div class="container">
            <h4 class="text-success">Form Validation With VueJs</h4>
            <div class="panel panel-primary">
                <div class="panel-heading">Form Validation With VueJs</div>
                <form class="form-horizontal" @submit="validateForm" method="POST">
                    <div class="panel-body">
                        <ul>
                            <li v-for="error in errors" style='color:red'>{{ error }}</li>
                        </ul>
                        <div class="form-group">
                            <label class="control-label col-sm-2">First name:</label>
                            <div class="col-sm-5">
                                <input class="form-control" type="text" name="first_name" v-model="first_name">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-sm-2">Last name:</label>
                            <div class="col-sm-5">
                                <input class="form-control" type="text" name="last_name" v-model="last_name">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-sm-2">Date Of Birth:</label>
                            <div class="col-sm-5">
                                <vuejs-datepicker  format='yyyy-MM-dd' :language="zh" name="birthday" v-model="birthday"></vuejs-datepicker>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-sm-2">Gender:</label>
                            <div class="col-sm-5">
                                <input type="radio" value="Male" name="gender" v-model="gender">Male
                                <input type="radio" value="Female" name="gender" v-model="gender">Female
                            </div>
                        </div>
                        <div class="form-group">
   .........完整代码请登录后点击上方下载按钮下载查看

网友评论0