/demo/uikit/stackedForm.html
HTML | 198 lines | 183 code | 15 blank | 0 comment | 0 complexity | 05423ce00ff581d5033e4dc4b03f6461 MD5 | raw file
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>FormValidation → UIKit demo</title>
- <link rel="stylesheet" href="http://cdn.jsdelivr.net/uikit/2.13.1/css/uikit.min.css"/>
- <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" />
- <link rel="stylesheet" href="../../dist/css/formValidation.css"/>
- <script type="text/javascript" src="../../vendor/jquery/jquery.min.js"></script>
- <script type="text/javascript" src="http://cdn.jsdelivr.net/uikit/2.13.1/js/uikit.min.js"></script>
- <script type="text/javascript" src="../../dist/js/formValidation.js"></script>
- <script type="text/javascript" src="../../dist/js/framework/uikit.js"></script>
- <style type="text/css">
- body {
- padding: 50px 0;
- }
- </style>
- </head>
- <body>
- <div class="uk-width-1-2 uk-container-center">
- <form id="stackedForm" class="uk-form uk-form-stacked">
- <h2>UIKit Form</h2>
- <hr/>
- <div class="uk-form-row">
- <label class="uk-form-label">Full name</label>
- <div class="uk-form-controls">
- <input name="firstName" type="text" placeholder="First name" />
- </div>
- </div>
- <div class="uk-form-row">
- <label class="uk-form-label"></label>
- <div class="uk-form-controls">
- <input name="lastName" type="text" placeholder="Last name" />
- </div>
- </div>
- <div class="uk-form-row">
- <label class="uk-form-label">Username</label>
- <div class="uk-form-controls">
- <input name="username" type="text" placeholder="Username" />
- </div>
- </div>
- <div class="uk-form-row">
- <label class="uk-form-label">Email address</label>
- <div class="uk-form-controls">
- <input name="email" type="text" placeholder="Email address" />
- </div>
- </div>
- <div class="uk-form-row">
- <label class="uk-form-label">Password</label>
- <div class="uk-form-controls">
- <input name="password" type="password" placeholder="Password" />
- </div>
- </div>
- <div class="uk-form-row">
- <label class="uk-form-label">Gender</label>
- <div class="uk-form-controls">
- <label><input name="gender" type="radio" value="male" /> Male</label> <br/>
- <label><input name="gender" type="radio" value="female" /> Female</label> <br/>
- <label><input name="gender" type="radio" value="other" /> Other</label>
- </div>
- </div>
- <div class="uk-form-row">
- <label class="uk-form-label" id="captchaOperation"></label>
- <div class="uk-form-controls">
- <input type="text" name="captcha" />
- </div>
- </div>
- <div class="uk-form-row">
- <label class="uk-form-label"></label>
- <div class="uk-form-controls">
- <label>
- <input name="agree" type="checkbox" /> Agree with the terms and conditions
- </label>
- </div>
- </div>
- <div class="uk-form-row">
- <label class="uk-form-label"></label>
- <div class="uk-form-controls">
- <button type="submit" class="uk-button uk-button-primary">Submit</button>
- </div>
- </div>
- </form>
- </div>
- <script type="text/javascript">
- $(document).ready(function() {
- // Generate a simple captcha
- function randomNumber(min, max) {
- return Math.floor(Math.random() * (max - min + 1) + min);
- };
- $('#captchaOperation').html([randomNumber(1, 100), '+', randomNumber(1, 200), '='].join(' '));
- $('#stackedForm').formValidation({
- framework: 'uikit',
- icon: {
- valid: 'fa fa-check',
- invalid: 'fa fa-times',
- validating: 'fa fa-refresh',
- feedback: 'fv-control-feedback'
- },
- fields: {
- firstName: {
- validators: {
- notEmpty: {
- message: 'The first name is required'
- }
- }
- },
- lastName: {
- validators: {
- notEmpty: {
- message: 'The last name is required'
- }
- }
- },
- username: {
- message: 'The username is not valid',
- validators: {
- notEmpty: {
- message: 'The username is required'
- },
- stringLength: {
- min: 6,
- max: 30,
- message: 'The username must be more than 6 and less than 30 characters long'
- },
- regexp: {
- regexp: /^[a-zA-Z0-9_\.]+$/,
- message: 'The username can only consist of alphabetical, number, dot and underscore'
- }
- }
- },
- email: {
- validators: {
- notEmpty: {
- message: 'The email address is required'
- },
- emailAddress: {
- message: 'The input is not a valid email address'
- }
- }
- },
- password: {
- validators: {
- notEmpty: {
- message: 'The password is required'
- },
- different: {
- field: 'username',
- message: 'The password cannot be the same as username'
- }
- }
- },
- gender: {
- validators: {
- notEmpty: {
- message: 'The gender is required'
- }
- }
- },
- captcha: {
- validators: {
- callback: {
- message: 'Wrong answer',
- callback: function(value, validator) {
- var items = $('#captchaOperation').html().split(' '), sum = parseInt(items[0]) + parseInt(items[2]);
- return value == sum;
- }
- }
- }
- },
- agree: {
- validators: {
- notEmpty: {
- message: 'You must agree with the terms and conditions'
- }
- }
- }
- }
- });
- });
- </script>
- </body>
- </html>