<!DOCTYPE html> <html> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script> <body> <h2>Company Type</h2> <p>Classification</p> <div ng-app="Classification" ng-controller="myCtrl"> <form name="myForm"> <select name="classifications" ng-model="selectedClassifications" ng-options="x.class for x in classifications"> <option value="" disabled selected>-Select Classification-</option> </select> <p>Specific Type</p> <select ng-model="selectedSpecificType" ng-options="y for y in selectedClassifications.type"> <option value="" disabled selected>-Select Type-</option> </select> <br> <h2>Proposed Names</h2> <p>Option 1</p> <input type="text" name="option1" ng-model="option1" placeholder="Option 1" ng-pattern="selectedClassifications.regex" ng-disabled="!selectedClassifications || !selectedSpecificType"> <span style="color:red" ng-show="myForm.option1.$error.pattern">enter a valid name</span> <br> <p>Option 2</p> <input type="text" placeholder="Option 2"> <br> <input type="submit" ng-model="submit" ng-disabled="!selectedClassifications || !selectedSpecificType || !option1" value="Save and Continue"> <br> </form> </div> <script> var app = angular.module('Classification', []); app.controller('myCtrl', function($scope) {$scope.classifications = [ {class : 'BUSINESS NAME', type: ["BUSINESS NAME"], regex : /^[\s\w]+[^(ltd|limited|plc)]$/}, {class : 'COMPANY', type : ["PRIVATE COMPANY LIMITED BY SHARES", "PUBLIC COMPANY LIMITED BY SHARES", "PRIVATE COMPANY LIMITED BY GUARANTEE", "PUBLIC COMPANY LIMITED BY GUARANTEE", "PRIVATE UNLIMITED COMPANY", "PUBLIC UNLIMITED COMPANY"]}, {class : 'INCORPORATED TRUSTEE', type : ["INCORPORATED TRUSTEE"], regex : /^[\s\w]+[^(ltd|limited|plc)]$/}]; $scope.option1=''; }); </script> </body> </html>