JSFiddle - React, Tailwind, and code Playground
HTML
<div class="">
<form name="loginForm" ng-submit="submitForm(loginForm.$valid)" ng-controller="LoginCtrl" novalidate>
<fieldset ng-class="{ 'vfnz-form--error' : loginForm.username.$invalid }">
<div class="form-input-error" ng-show="loginForm.username.$error.maxlength">
Username is too long.
</div>
<div class="vfnz-fieldWrapper">
<input
type="text"
id="username"
name="username"
ng-model="username"
class="vfnz-input--text"
placeholder="Username"
ng-maxlength="8"
required />
<label for="name" class="vfnz-input-label">
Username
</label>
</div>
</fieldset>
<fieldset ng-class="{ 'vfnz-form--error' : loginForm.password.$invalid && !loginForm.password.$pristine }">
<div class="form-input-error" ng-show="loginForm.password.$error.minlength">
Password must be 6 or more characters.
</div>
<div class="vfnz-fieldWrapper">
<input
type="password"
id="password"
name="password"
ng-model="password"
class="vfnz-input--text"
placeholder="Password"
ng-minlength="6"
required />
<label for="password" class="vfnz-input-label">
Password
</label>
</div>
</fieldset>
<button type="submit" ng-disabled="loginForm.$invalid" class="vfnz-submit">Login</button>
</form>
</div>
CSS
/*-- DO NOT REMOVE THIS - This is for an enhanced grid system and makes
for easier sizing options --*/
*, *:before, *:after {
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
-o-box-sizing: border-box;
}
/*----------------------------------*/
body {
background:#eee;
}
form {
background:#fff;
padding:2em;
width: 100%;
margin: 10px auto;
border-radius:3px;
box-shadow:0 1px 2px rgba(0,0,0,.25);
font-family: Arial, Helvetica, sans-serif;
font-weight: normal;
font-size: 14px;
}
fieldset {
border: none;
position: relative;
padding: 0;
margin: 10px 0;
}
.vfnz-fieldWrapper:after, .vfnz-areaWrapper:after {
/* TO BE REPLACED WITH VFICONS */
content: url(http://i.imgur.com/pWF7Pnw.png);
display: block;
width: 16px;
height: 16px;
position: absolute;
top: 34%;
right: 10px;
filter: alpha(opacity=0);
opacity:0;
transition: opacity 0.3s linear;
-webkit-transition: opacity 0.3s linear;
-moz-transition: opacity 0.3s linear;
-0-transition: opacity 0.3s linear;
}
.vfnz-areaWrapper:after {
top: 15px;
}
.vfnz-fieldWrapper {
position:relative;
}
.vfnz-input--text, .vfnz-input--textarea {
border: 1px solid #cccccc;
color: #666666;
padding-left: 10px;
width: 100%;
height: 50px;
border-radius: 3px;
font-size: 14px;
font-weight: normal;
transition: all 0.2s ease 0s;
-webkit-transition: all 0.2s ease 0s;
-moz-transition: all 0.2s ease 0s;
-0-transition: all 0.2s ease 0s;
}
.vfnz-input--textarea {
height: inherit;
padding: 15px 28px 15px 10px;
font-family: Arial, Helvetica, sans-serif;
font-weight: normal;
margin: 0;
}
/* TO FIX THE X ON IE >=10 */
::-ms-clear, ::-ms-reveal {
display: none;
width: 0;
height: 0;
}
.vfnz-input--text:focus, .vfnz-input--textarea:focus {
outline:none;
border: 1px solid #999999;
...
JavaScript
var validationApp = angular.module('validationApp', []);
validationApp.controller('LoginCtrl', function($scope){
// Function to submit the form after all validation has occurred
$scope.submitForm = function(isValid) {
// Errors to show on submit - keep value set to true
$scope.submitted = true;
// Check to make sure the form is completely valid
if (isValid) {
alert('Form is valid');
}
};
});