cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

            
              <div class="oj-web-applayout-content oj-web-applayout-max-width">
   <div id="form-container" class="oj-form-layout container">
      <div class="card">
         <h1>Shipping Info for this lesson is now being updated </h1>
          <div class="oj-flex"> 
               <div class="oj-flex-item">     
                <div class="oj-flex oj-sm-flex-direction-column">      
                  <div class="oj-flex-item">
                   <label for="name">Full Name</label>              
                  </div>
                  <div class="oj-flex-item">
                    <input id="name" 
                       data-bind="ojComponent:{
                       component: 'ojInputText', 
                       value: fullname,
                       rootAttributes: {
                         style:'max-width:100%'
                       },
                       invalidComponentTracker: tracker,
                       required: true                            
                    }">
                  </div>  
                  <div class="oj-flex-item">
                     <label for="address">Address</label>
                  </div>
                  <div class="oj-flex-item">  
                    <input id="address" 
                       data-bind="ojComponent:{
                       component: 'ojInputText', 
                       value: address,
                       rootAttributes: {
                         style:'max-width:100%'
                       },
                       placeholder:'Street address, P.O. Box, company name, c/o',
                       required: false
                       }">
                  </div>
                  
     </div>
  </div>
          </div>
     </div>
      <div class="card">
            <h1>Payment Info </h1>
              <div class="oj-flex oj-sm-only-flex-direction-column oj-md-only-flex-direction-column oj-lg-flex-items-1 oj-form-layout" id="subform-container"> 
                    <div class="oj-md-8 oj-lg-12 oj-flex-item">
                     <label for="cardnumber">Card Number</label> 
                     <input id="cardnumber" title="Enter a valid credit card no."
                       data-bind="ojComponent:{
                       component: 'ojInputText',
                       rootAttributes: {
                         style:'max-width:100%'
                       }, 
                       value: cardnumber,
                       invalidComponentTracker: tracker,
                       placeholder:'xxxx-xxxx-xxxx-xxxxx',
                       validators: [{
                         type: 'regExp', 
                         options: {
                         pattern: '[0-9]{10,}', 
                         messageDetail: 'You must enter a valid card number, i.e. 10 digits'}}],
                       required: true                            
                      }">
                    </div>
                <div class="oj-md-8 oj-lg-4 oj-flex-item">
                        <label for="cardtype">Type</label>
                        <input id="cardtype" 
                          data-bind="ojComponent:{
                          component: 'ojInputText', 
                          value: cardtype,
                          rootAttributes: {
                           style:'max-width:100%'
                          }, 
                          required: true,
                          disabled: true,
                          placeholder: '--'                            
                          }">          
                     </div>
  </div>
         <div class="oj-flex">
                  <div class="submit-container">
                    <button class="oj-button-primary oj-button-xl"
                       data-bind="click: submitInfo,
                        ojComponent: {
                          component:'ojButton', label: 'Submit',
                          icons: {start:'oj-fwk-icon oj-fwk-icon-clock'},
                          chroming: 'full',
                          disabled: shouldDisableSubmit() 
                     }">
                   </button>
                  </div>
                </div>
</div>
            
          
!
            
              @import url('//cdn.rawgit.com/oracle/oraclejet/2a420014546d371d076ec741ef171f0a3c71f28d/dist/css/alta/oj-alta-min.css');

.card {
    padding: 10px;
    margin: 20px 0;
    height: auto;
    box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2);
}
.card h2 {
    font-size: 2.5rem;
    margin-top: 0;
    margin-bottom: 30px;
}

.submit-container {
    margin-top: 40px;
    text-align: center;
    width: 100%;
}
.container {
	display: block;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
}

            
          
!
            
              requirejs.config({
  // Path mappings for the logical module names
  paths: {
    'knockout': '//cdnjs.cloudflare.com/ajax/libs/knockout/3.4.0/knockout-min',
    'jquery': '//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min',
    "jqueryui": "//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui",
    "jqueryui-amd": "//cdn.rawgit.com/jquery/jquery-ui/1-11-stable/ui",

    "promise": "//cdn.rawgit.com/components/es6-promise/c95149ffaa2e8162601c57d4282362eac84f929b/promise.min",
    "hammerjs": "//cdnjs.cloudflare.com/ajax/libs/hammer.js/2.0.4/hammer.min",
    "ojdnd": "//cdn.rawgit.com/oracle/oraclejet/2a420014546d371d076ec741ef171f0a3c71f28d/dist/js/libs/dnd-polyfill/dnd-polyfill-1.0.0.min",
    "ojs": "//cdn.rawgit.com/oracle/oraclejet/2a420014546d371d076ec741ef171f0a3c71f28d/dist/js/libs/oj/min",
    "ojL10n": "//cdn.rawgit.com/oracle/oraclejet/2a420014546d371d076ec741ef171f0a3c71f28d/dist/js/libs/oj/ojL10n",
    "ojtranslations": "//cdn.rawgit.com/oracle/oraclejet/2a420014546d371d076ec741ef171f0a3c71f28d/dist/js/libs/oj/resources",
    "text": "//cdnjs.cloudflare.com/ajax/libs/require-text/2.0.12/text.min",
    "signals": "//cdnjs.cloudflare.com/ajax/libs/js-signals/1.0.0/js-signals.min"
  },
  // Shim configurations for modules that do not expose AMD
  shim: {
    'jqueryui-amd': {
      exports: "$",
      deps: ['jquery']
    },
    'jquery': {
      exports: ['jQuery', '$']
    }
  },
  config: {
    ojL10n: {
      merge: {
        //'ojtranslations/nls/ojtranslations': 'resources/nls/menu'
        // The following addes en-US to the r.js bundle
        //'ojtranslations/nls/ojtranslations': '../../oj/resources/nls/en-US/localeElements'
      }
    }
  }
});

require(['knockout',
  'ojs/ojcore',
  'ojs/ojknockout',
  'ojs/ojinputtext',
  'ojs/ojbutton',
  'ojs/ojknockout-validation',
  'https://s3-us-west-2.amazonaws.com/s.cdpn.io/343811/MessageBundle.js'
], function(ko, oj) {
  'use strict';
  
 
  
  var ViewModel = function() {
    var self = this;
    
    self.fullname = ko.observable();
    self.email = ko.observable();
    self.phone = ko.observable();
    self.address = ko.observable();
    // Shopping cart variables
    self.cardtype = ko.observable();
    self.cardnumber = ko.observable();
    
    // InvalidComponentTracker attribute
    self.tracker = ko.observable();
    
    
    // button submision 
    self.submitInfo = function(data, event){
      var trackerObj = ko.utils.unwrapObservable(self.tracker);

      // Step 1
      if (!this._showComponentValidationErrors(trackerObj)){
          return;
       }
      // All is well here
       alert("Information submitted successfully!!")
    };
    self.shouldDisableSubmit = function () {
       var trackerObj = ko.utils.unwrapObservable(self.tracker), 
            hasInvalidComponents = trackerObj ? trackerObj["invalidShown"] : false;
       
      return  hasInvalidComponents;
    };
    // P R I V A T E    M E T H O D S

    // Returns false if there are components showing errors. Returns 
    // true if all components are valid.
    self._showComponentValidationErrors = function (trackerObj){
        trackerObj.showMessages();
        if (trackerObj.focusOnFirstInvalid())
          return false;

        return true;
    };
    
  };
  
  ko.applyBindings(new ViewModel());
});
            
          
!
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.
Loading ..................

Console