Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <link href="//cdn.jsdelivr.net/picnicss/4.1.1/picnic.min.css" rel="stylesheet">
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <h1>Hello Mag.JS!</h1>
  <a target="_top" href="https://github.com/magnumjs/mag.js">GitHub</a>
  <hr/>
  <div id="validate">
    <label>Name:</label>
    <input type="text" class="form-control" name="transaksiQty" value="datafromserver" />
    <hr/>
  </div>
  <script src="//rawgit.com/magnumjs/mag.js/master/dist/mag.0.23.9.min.js"></script>
</body>
</html>
 
.hide {
  display: none;
}
a { display: block;}
a:after {content:" \bb";}
 
var props = {
  limit: 10
};
mag.module("validate", {
  view: function(state, props) {
    state.input = {
      _config: function(node, isNew) {
        // runs only onload initially
        if (isNew && node.value.length > props.limit) {
          console.log('data is larger than the limit of: ' + props.limit);
          //trim size based on limit or simply remove it ?
          // TO remove
          //node.value = '';
          //TO trim based on limit
          node.value = node.value.substr(0, props.limit);
        }
      }
    };
  }
}, props);
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers