Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div ng-app="myApp">
    <form name="my_form"
          class="main-form container ng-scope ng-invalid ng-dirty ng-valid-email ng-valid-record-taken ng-valid-record-loading ng-valid-maxlength ng-valid-password-characters ng-valid-minlength ng-valid-match ng-invalid-date ng-invalid-pattern ng-valid-required"
          ng-controller="FormCtrl" ng-submit="submit()" novalidate="">
        <div class="control-group">
            <label for="input_first_name">Name:</label>

            <div class="row">
                <div class="col-md-6">
                    <input class="form-control ng-dirty ng-valid ng-valid-required" name="first_name"
                           id="input_first_name"
                           ng-model="data.first_name" required="" type="text">
                    <!-- ngIf: interacted(my_form.first_name) -->
                    <div class="error-messages ng-scope ng-inactive" ng-if="interacted(my_form.first_name)"
                         ng-messages="my_form.first_name.$error" ng-messages-include="form-messages">
                        <small ng-message="required">
                            Make sure you enter you first_name
                        </small>
                        <small ng-message="password-characters">
                            password-characters.error
                        </small>
                        <small ng-message="pattern">
                            Please choose another
                        </small>
                        <small ng-message="email">
                            email error
                        </small>
                        <small ng-message="minlength">
                            minLength 3
                        </small>
                        <small ng-message="maxlength">
                            maxLength 20
                        </small>
                    </div>
                    <!-- end ngIf: interacted(my_form.first_name) -->
                </div>
                <div class="col-md-6">
                    <input class="form-control ng-dirty ng-valid ng-valid-required" name="last_name"
                           id="input_last_name"
                           ng-model="data.last_name" required="" type="text">
                    <!-- ngIf: interacted(my_form.last_name) -->
                    <div class="error-messages ng-scope ng-inactive" ng-if="interacted(my_form.last_name)"
                         ng-messages="my_form.last_name.$error" ng-messages-include="form-messages">
                        <small ng-message="required">
                            Make sure you enter you last_name
                        </small>
                        <small ng-message="password-characters">
                            password-characters.error
                        </small>
                        <small ng-message="pattern">
                            Please choose another
                        </small>
                        <small ng-message="email">
                            email error
                        </small>
                        <small ng-message="minlength">
                            minLength 3
                        </small>
                        <small ng-message="maxlength">
                            maxLength 20
                        </small>
                    </div>
                    <!-- end ngIf: interacted(my_form.last_name) -->
                </div>
            </div>
        </div>

        <div class="control-group">
            <label for="input_username">Choose your Username:</label>
            <input class="form-control ng-dirty ng-valid-required ng-valid-minlength ng-valid-record-taken ng-valid ng-valid-record-loading"
                   name="username" id="input_username" ng-model="data.username" ng-minlength="6"
                   fake-remote-record-validator="fakeUsernames" required="" type="text">
            <!-- ngIf: interacted(my_form.username) -->
            <div class="error-messages ng-scope ng-inactive" ng-if="interacted(my_form.username)"
                 ng-messages="my_form.username.$error" ng-messages-include="form-messages">
                <small ng-message="required">
                    Make sure you enter you username
                </small>
                <small ng-message="password-characters">
                    password-characters.error
                </small>
                <small ng-message="pattern">
                    Please choose another
                </small>
                <small ng-message="email">
                    email error
                </small>
                <small ng-message="minlength">
                    minLength 3
                </small>
                <small ng-message="maxlength">
                    maxLength 20
                </small>
                <small ng-message="record-loading">
                    record-loading error
                </small>
                <small ng-message="record-taken">
                    record-taken error
                </small>
            </div>
            <!-- end ngIf: interacted(my_form.username) -->
        </div>

        <div class="control-group">
            <label for="input_email_address">Email Address:</label>
            <input class="form-control ng-dirty ng-valid-required ng-valid-email ng-valid-record-taken ng-valid ng-valid-record-loading"
                   name="email_address" id="input_email_address" ng-model="data.email_address"
                   fake-remote-record-validator="fakeEmails" required="" type="email">
            <!-- ngIf: interacted(my_form.email_address) -->
            <div class="error-messages ng-scope ng-inactive" ng-if="interacted(my_form.email_address)"
                 ng-messages="my_form.email_address.$error" ng-messages-include="form-messages">
                <small ng-message="required">
                    Make sure you enter you email address
                </small>
                <small ng-message="password-characters">
                    password-characters.error
                </small>
                <small ng-message="pattern">
                    Please choose another
                </small>
                <small ng-message="email">
                    email error
                </small>
                <small ng-message="minlength">
                    minLength 3
                </small>
                <small ng-message="maxlength">
                    maxLength 20
                </small>
                <small ng-message="record-loading">
                    record-loading error
                </small>
                <small ng-message="record-taken">
                    record-taken error
                </small>
            </div>
            <!-- end ngIf: interacted(my_form.email_address) -->
        </div>

        <div class="control-group">
            <label for="input_password">Create a password:</label>
            <input class="form-control ng-dirty ng-valid-maxlength ng-valid-required ng-valid-password-characters ng-valid ng-valid-minlength"
                   name="password" id="input_password" ng-model="data.password" ng-minlength="6" ng-maxlength="12"
                   password-characters-validator="" required="" type="password">
            <!-- ngIf: interacted(my_form.password) -->
            <div class="error-messages ng-scope ng-inactive" ng-if="interacted(my_form.password)"
                 ng-messages="my_form.password.$error" ng-messages-include="form-messages">
                <small ng-message="required">
                    Make sure you enter you password
                </small>
                <small ng-message="password-characters">
                    password-characters.error
                </small>
                <small ng-message="pattern">
                    Please choose another
                </small>
                <small ng-message="email">
                    email error
                </small>
                <small ng-message="minlength">
                    minLength 3
                </small>
                <small ng-message="maxlength">
                    maxLength 20
                </small>
            </div>
            <!-- end ngIf: interacted(my_form.password) -->
        </div>

        <div class="control-group">
            <label for="input_password_confirm">Confirm your password:</label>
            <input class="form-control ng-valid-maxlength ng-dirty ng-valid-required ng-valid-password-characters ng-valid-minlength ng-valid ng-valid-match"
                   name="password_confirm" id="input_password_confirm" ng-model="data.password_confirm" ng-minlength="6"
                   ng-maxlength="12" password-characters-validator="" match-validator="data.password" required=""
                   type="password">
            <!-- ngIf: interacted(my_form.password_confirm) -->
            <div class="error-messages ng-scope ng-inactive" ng-if="interacted(my_form.password_confirm)"
                 ng-messages="my_form.password_confirm.$error" ng-messages-include="form-messages">
                <small ng-message="required">
                    Make sure you enter you password confirm
                </small>
                <small ng-message="password-characters">
                    password-characters.error
                </small>
                <small ng-message="pattern">
                    Please choose another
                </small>
                <small ng-message="email">
                    email error
                </small>
                <small ng-message="minlength">
                    minLength 3
                </small>
                <small ng-message="maxlength">
                    maxLength 20
                </small>
            </div>
            <!-- end ngIf: interacted(my_form.password_confirm) -->
        </div>

        <div class="control-group">
            <label for="input_dob">Birthday:</label>
            <input class="form-control ng-dirty ng-valid-required ng-invalid ng-invalid-date" name="dob" id="input_dob"
                   ng-model="data.dob" required="" type="date">
            <!-- ngIf: interacted(my_form.dob) -->
            <div class="error-messages ng-scope ng-inactive" ng-if="interacted(my_form.dob)"
                 ng-messages="my_form.dob.$error" ng-messages-include="form-messages">
                <small ng-message="required">
                    Make sure you enter you dob
                </small>
                <small ng-message="password-characters">
                    password-characters.error
                </small>
                <small ng-message="pattern">
                    Please choose another
                </small>
                <small ng-message="email">
                    email error
                </small>
                <small ng-message="minlength">
                    minLength 3
                </small>
                <small ng-message="maxlength">
                    maxLength 20
                </small>
            </div>
            <!-- end ngIf: interacted(my_form.dob) -->
        </div>

        <div class="control-group">
            <label for="input_gender">Gender:</label>
            <select class="form-control ng-dirty ng-valid ng-valid-required" name="gender" id="input_gender"
                    ng-model="data.gender" ng-options="gender for gender in genders" required="">
                <option selected="selected" value="0">Male</option>
                <option value="1">Female</option>
            </select>
            <!-- ngIf: interacted(my_form.gender) -->
            <div class="error-messages ng-scope ng-inactive" ng-if="interacted(my_form.gender)"
                 ng-messages="my_form.gender.$error" ng-messages-include="form-messages">
                <small ng-message="required">
                    Make sure you enter you gender
                </small>
                <small ng-message="password-characters">
                    password-characters.error
                </small>
                <small ng-message="pattern">
                    Please choose another
                </small>
                <small ng-message="email">
                    email error
                </small>
                <small ng-message="minlength">
                    minLength 3
                </small>
                <small ng-message="maxlength">
                    maxLength 20
                </small>
            </div>
            <!-- end ngIf: interacted(my_form.gender) -->
        </div>

        <div class="control-group">
            <label for="input_phone">Phone Number:</label>
            <input class="form-control ng-dirty ng-valid-required ng-invalid ng-invalid-pattern" name="phone"
                   id="input_phone" ng-model="data.phone" ng-pattern="phoneNumberRegex" required="" type="text">
            <!-- ngIf: interacted(my_form.phone) -->
            <div class="error-messages ng-scope ng-active" ng-if="interacted(my_form.phone)"
                 ng-messages="my_form.phone.$error" ng-messages-include="form-messages">
                <small ng-message="required">
                    Make sure you enter you Phone Number
                </small>
                <small ng-message="password-characters">
                    password-characters.error
                </small>
                <small ng-message="pattern">
                    Please choose another
                </small>
                <small ng-message="email">
                    email error
                </small>
                <small ng-message="minlength">
                    minLength 3
                </small>
                <small ng-message="maxlength">
                    maxLength 20
                </small>
                <div class="ng-scope" ng-message="pattern">Please enter your phone number in the format of: (XXX)
                    YYY-ZZZZ
                </div>
            </div>
            <!-- end ngIf: interacted(my_form.phone) -->
        </div>

        <div class="control-group">
            <label for="input_location">Location:</label>
            <select class="form-control ng-dirty ng-valid ng-valid-required" name="location" id="input_location"
                    ng-model="data.location" ng-options="location.code as location.name for location in locations"
                    required="">
                <option selected="selected" value="0">Afghanistan</option>
                <option value="1">Åland Islands</option>
                <option value="2">Albania</option>
                <option value="3">Algeria</option>
                <option value="4">American Samoa</option>
                <option value="5">AndorrA</option>
                <option value="6">Angola</option>
                <option value="7">Anguilla</option>
                <option value="8">Antarctica</option>
                <option value="9">Antigua and Barbuda</option>
                <option value="10">Argentina</option>
                <option value="11">Armenia</option>
                <option value="12">Aruba</option>
                <option value="13">Australia</option>
                <option value="14">Austria</option>
                <option value="15">Azerbaijan</option>
                <option value="16">Bahamas</option>
                <option value="17">Bahrain</option>
                <option value="18">Bangladesh</option>
                <option value="19">Barbados</option>
                <option value="20">Belarus</option>
                <option value="21">Belgium</option>
                <option value="22">Belize</option>
                <option value="23">Benin</option>
                <option value="24">Bermuda</option>
                <option value="25">Bhutan</option>
                <option value="26">Bolivia</option>
                <option value="27">Bosnia and Herzegovina</option>
                <option value="28">Botswana</option>
                <option value="29">Bouvet Island</option>
                <option value="30">Brazil</option>
                <option value="31">British Indian Ocean Territory</option>
                <option value="32">Brunei Darussalam</option>
                <option value="33">Bulgaria</option>
                <option value="34">Burkina Faso</option>
                <option value="35">Burundi</option>
                <option value="36">Cambodia</option>
                <option value="37">Cameroon</option>
                <option value="38">Canada</option>
                <option value="39">Cape Verde</option>
                <option value="40">Cayman Islands</option>
                <option value="41">Central African Republic</option>
                <option value="42">Chad</option>
                <option value="43">Chile</option>
                <option value="44">China</option>
                <option value="45">Christmas Island</option>
                <option value="46">Cocos (Keeling) Islands</option>
                <option value="47">Colombia</option>
                <option value="48">Comoros</option>
                <option value="49">Congo</option>
                <option value="50">Congo, The Democratic Republic of the</option>
                <option value="51">Cook Islands</option>
                <option value="52">Costa Rica</option>
                <option value="53">Cote D"Ivoire</option>
                <option value="54">Croatia</option>
                <option value="55">Cuba</option>
                <option value="56">Cyprus</option>
                <option value="57">Czech Republic</option>
                <option value="58">Denmark</option>
                <option value="59">Djibouti</option>
                <option value="60">Dominica</option>
                <option value="61">Dominican Republic</option>
                <option value="62">Ecuador</option>
                <option value="63">Egypt</option>
                <option value="64">El Salvador</option>
                <option value="65">Equatorial Guinea</option>
                <option value="66">Eritrea</option>
                <option value="67">Estonia</option>
                <option value="68">Ethiopia</option>
                <option value="69">Falkland Islands (Malvinas)</option>
                <option value="70">Faroe Islands</option>
                <option value="71">Fiji</option>
                <option value="72">Finland</option>
                <option value="73">France</option>
                <option value="74">French Guiana</option>
                <option value="75">French Polynesia</option>
                <option value="76">French Southern Territories</option>
                <option value="77">Gabon</option>
                <option value="78">Gambia</option>
                <option value="79">Georgia</option>
                <option value="80">Germany</option>
                <option value="81">Ghana</option>
                <option value="82">Gibraltar</option>
                <option value="83">Greece</option>
                <option value="84">Greenland</option>
                <option value="85">Grenada</option>
                <option value="86">Guadeloupe</option>
                <option value="87">Guam</option>
                <option value="88">Guatemala</option>
                <option value="89">Guernsey</option>
                <option value="90">Guinea</option>
                <option value="91">Guinea-Bissau</option>
                <option value="92">Guyana</option>
                <option value="93">Haiti</option>
                <option value="94">Heard Island and Mcdonald Islands</option>
                <option value="95">Holy See (Vatican City State)</option>
                <option value="96">Honduras</option>
                <option value="97">Hong Kong</option>
                <option value="98">Hungary</option>
                <option value="99">Iceland</option>
                <option value="100">India</option>
                <option value="101">Indonesia</option>
                <option value="102">Iran, Islamic Republic Of</option>
                <option value="103">Iraq</option>
                <option value="104">Ireland</option>
                <option value="105">Isle of Man</option>
                <option value="106">Israel</option>
                <option value="107">Italy</option>
                <option value="108">Jamaica</option>
                <option value="109">Japan</option>
                <option value="110">Jersey</option>
                <option value="111">Jordan</option>
                <option value="112">Kazakhstan</option>
                <option value="113">Kenya</option>
                <option value="114">Kiribati</option>
                <option value="115">Korea, Democratic People"S Republic of</option>
                <option value="116">Korea, Republic of</option>
                <option value="117">Kuwait</option>
                <option value="118">Kyrgyzstan</option>
                <option value="119">Lao People"S Democratic Republic</option>
                <option value="120">Latvia</option>
                <option value="121">Lebanon</option>
                <option value="122">Lesotho</option>
                <option value="123">Liberia</option>
                <option value="124">Libyan Arab Jamahiriya</option>
                <option value="125">Liechtenstein</option>
                <option value="126">Lithuania</option>
                <option value="127">Luxembourg</option>
                <option value="128">Macao</option>
                <option value="129">Macedonia, The Former Yugoslav Republic of</option>
                <option value="130">Madagascar</option>
                <option value="131">Malawi</option>
                <option value="132">Malaysia</option>
                <option value="133">Maldives</option>
                <option value="134">Mali</option>
                <option value="135">Malta</option>
                <option value="136">Marshall Islands</option>
                <option value="137">Martinique</option>
                <option value="138">Mauritania</option>
                <option value="139">Mauritius</option>
                <option value="140">Mayotte</option>
                <option value="141">Mexico</option>
                <option value="142">Micronesia, Federated States of</option>
                <option value="143">Moldova, Republic of</option>
                <option value="144">Monaco</option>
                <option value="145">Mongolia</option>
                <option value="146">Montserrat</option>
                <option value="147">Morocco</option>
                <option value="148">Mozambique</option>
                <option value="149">Myanmar</option>
                <option value="150">Namibia</option>
                <option value="151">Nauru</option>
                <option value="152">Nepal</option>
                <option value="153">Netherlands</option>
                <option value="154">Netherlands Antilles</option>
                <option value="155">New Caledonia</option>
                <option value="156">New Zealand</option>
                <option value="157">Nicaragua</option>
                <option value="158">Niger</option>
                <option value="159">Nigeria</option>
                <option value="160">Niue</option>
                <option value="161">Norfolk Island</option>
                <option value="162">Northern Mariana Islands</option>
                <option value="163">Norway</option>
                <option value="164">Oman</option>
                <option value="165">Pakistan</option>
                <option value="166">Palau</option>
                <option value="167">Palestinian Territory, Occupied</option>
                <option value="168">Panama</option>
                <option value="169">Papua New Guinea</option>
                <option value="170">Paraguay</option>
                <option value="171">Peru</option>
                <option value="172">Philippines</option>
                <option value="173">Pitcairn</option>
                <option value="174">Poland</option>
                <option value="175">Portugal</option>
                <option value="176">Puerto Rico</option>
                <option value="177">Qatar</option>
                <option value="178">Reunion</option>
                <option value="179">Romania</option>
                <option value="180">Russian Federation</option>
                <option value="181">RWANDA</option>
                <option value="182">Saint Helena</option>
                <option value="183">Saint Kitts and Nevis</option>
                <option value="184">Saint Lucia</option>
                <option value="185">Saint Pierre and Miquelon</option>
                <option value="186">Saint Vincent and the Grenadines</option>
                <option value="187">Samoa</option>
                <option value="188">San Marino</option>
                <option value="189">Sao Tome and Principe</option>
                <option value="190">Saudi Arabia</option>
                <option value="191">Senegal</option>
                <option value="192">Serbia and Montenegro</option>
                <option value="193">Seychelles</option>
                <option value="194">Sierra Leone</option>
                <option value="195">Singapore</option>
                <option value="196">Slovakia</option>
                <option value="197">Slovenia</option>
                <option value="198">Solomon Islands</option>
                <option value="199">Somalia</option>
                <option value="200">South Africa</option>
                <option value="201">South Georgia and the South Sandwich Islands</option>
                <option value="202">Spain</option>
                <option value="203">Sri Lanka</option>
                <option value="204">Sudan</option>
                <option value="205">Suriname</option>
                <option value="206">Svalbard and Jan Mayen</option>
                <option value="207">Swaziland</option>
                <option value="208">Sweden</option>
                <option value="209">Switzerland</option>
                <option value="210">Syrian Arab Republic</option>
                <option value="211">Taiwan, Province of China</option>
                <option value="212">Tajikistan</option>
                <option value="213">Tanzania, United Republic of</option>
                <option value="214">Thailand</option>
                <option value="215">Timor-Leste</option>
                <option value="216">Togo</option>
                <option value="217">Tokelau</option>
                <option value="218">Tonga</option>
                <option value="219">Trinidad and Tobago</option>
                <option value="220">Tunisia</option>
                <option value="221">Turkey</option>
                <option value="222">Turkmenistan</option>
                <option value="223">Turks and Caicos Islands</option>
                <option value="224">Tuvalu</option>
                <option value="225">Uganda</option>
                <option value="226">Ukraine</option>
                <option value="227">United Arab Emirates</option>
                <option value="228">United Kingdom</option>
                <option value="229">United States</option>
                <option value="230">United States Minor Outlying Islands</option>
                <option value="231">Uruguay</option>
                <option value="232">Uzbekistan</option>
                <option value="233">Vanuatu</option>
                <option value="234">Venezuela</option>
                <option value="235">Viet Nam</option>
                <option value="236">Virgin Islands, British</option>
                <option value="237">Virgin Islands, U.S.</option>
                <option value="238">Wallis and Futuna</option>
                <option value="239">Western Sahara</option>
                <option value="240">Yemen</option>
                <option value="241">Zambia</option>
                <option value="242">Zimbabwe</option>
            </select>
            <!-- ngIf: interacted(my_form.location) -->
            <div class="error-messages ng-scope ng-inactive" ng-if="interacted(my_form.location)"
                 ng-messages="my_form.location.$error" ng-messages-include="form-messages">
                <small ng-message="required">
                    Make sure you enter you location
                </small>
                <small ng-message="password-characters">
                    password-characters.error
                </small>
                <small ng-message="pattern">
                    Please choose another
                </small>
                <small ng-message="email">
                    email error
                </small>
                <small ng-message="minlength">
                    minLength 3
                </small>
                <small ng-message="maxlength">
                    maxLength 20
                </small>
            </div>
            <!-- end ngIf: interacted(my_form.location) -->
        </div>
        <div class="control-group">
            <label>submit:</label>
            <input class="form-control" type="submit">
        </div>
    </form>
</div>
            
          
!
            
              angular.module('myApp', ['ngMessages'])
            .controller('FormCtrl', function ($scope, $http) {
                $scope.genders = [
                    'Male',
                    'Female'
                ];

                $http.get('./locations.json').success(function (locations) {
                    $scope.locations = locations;
                });

                $scope.phoneNumberRegex = /\(\d{3}\) \d{3}-\d{4}/;

                $scope.fakeUsernames = ['angular', 'username', 'user', 'john', 'eric', 'noob', 'ng'];
                $scope.fakeEmails = [
                    'email@email.com',
                    'email@gmail.com',
                    'email@website.com',
                    'jon@gmail.com',
                    'fake@gmail.com',
                    'fake@email.com'
                ];

                $scope.submitted = false;
                $scope.submit = function () {
                    $scope.submitted = true;
                };
                $scope.interacted = function (field) {
                    return $scope.submitted || field.$dirty;
                };
            })
            .factory('fakeQueryService', function ($timeout, $q) {
                var FAKE_TIMEOUT = 2000;
                return function (username, fakeInvalidData) {
                    var defer = $q.defer();
                    $timeout(function () {
                        fakeInvalidData.indexOf(username) == -1
                                ? defer.resolve()
                                : defer.reject();
                    }, FAKE_TIMEOUT);
                    return defer.promise;
                }
            })
            .directive('fakeRemoteRecordValidator', ['$timeout', 'fakeQueryService', function ($timeout, fakeQueryService) {
                return {
                    require: 'ngModel',
                    link: function (scope, element, attrs, ngModel) {
                        var seedData = scope.$eval(attrs.fakeRemoteRecordValidator);
                        ngModel.$parsers.push(function (value) {
                            valid(false);
                            loading(true);
                            fakeQueryService(value, seedData).then(
                                    function () {
                                        valid(true);
                                        loading(false);
                                    },
                                    function () {
                                        valid(false);
                                        loading(false);
                                    }
                            );
                            return value;
                        });

                        function valid(bool) {
                            ngModel.$setValidity('record-taken', bool);
                        }

                        function loading(bool) {
                            ngModel.$setValidity('record-loading', !bool);
                        }
                    }
                }
            }])
            .directive('matchValidator', function () {
                return {
                    require: 'ngModel',
                    link: function (scope, element, attrs, ngModel) {
                        ngModel.$parsers.push(function (value) {
                            ngModel.$setValidity('match', value == scope.$eval(attrs.matchValidator));
                            return value;
                        });
                    }
                }
            })
            .directive('passwordCharactersValidator', function () {
                var PASSWORD_FORMATS = [
                    /[^\w\s]+/, //special characters
                    /[A-Z]+/, //uppercase letters
                    /\w+/, //other letters
                    /\d+/ //numbers
                ];

                return {
                    require: 'ngModel',
                    link: function (scope, element, attrs, ngModel) {
                        ngModel.$parsers.push(function (value) {
                            var status = true;
                            angular.forEach(PASSWORD_FORMATS, function (regex) {
                                status = status && regex.test(value);
                            });
                            ngModel.$setValidity('password-characters', status);
                            return value;
                        });
                    }
                }
            })
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console