こんにちは、プログラミング初心者です。
現在、Monaca(HTML5+Javascriptのハイブリッドアプリ開発プラットフォーム)のベーシックプランにて初めてのアプリ開発に取り組んでいます。
その中で、Textarea内に文字制限を設け、超過すると警告ウインドウが出てくる仕組みを作っています。具体的には、ブラウザに依存するalertタグではなく、Tangle.jsというモーダルプラグインをダウンロードし、そのコードをTangle.jsホームページを参照して書き込みました。
現段階では、ユーザーが文字数制限を超えてTextarea内に入力を行った場合にこのモーダルウィンドウを警告として表示させたいのですが、その出し方がわかりません。以下がそのコードです。
<link rel="stylesheet" href="www/tingle.min.css">
Javascript
1<script type="text/javascript" src="www/tingle.min.js"> 2// instanciate new modal 3var modal = new tingle.modal({ 4 footer: true, 5 stickyFooter: false, 6 closeMethods: ['overlay', 'button', 'escape'], 7 closeLabel: "Close", 8 cssClass: ['custom-class-1', 'custom-class-2'], 9 onOpen: function() { 10 console.log('modal open'); 11 }, 12 onClose: function() { 13 console.log('modal closed'); 14 }, 15 beforeClose: function() { 16 // here's goes some logic 17 // e.g. save content before closing the modal 18 return true; // close the modal 19 return false; // nothing happens 20 } 21}); 22 23// set content 24modal.setContent('<h1>here\'s some content</h1>'); 25 26// add a button 27modal.addFooterBtn('Button label', 'tingle-btn tingle-btn--primary', function() { 28 // here goes some logic 29 modal.close(); 30}); 31 32// add another button 33modal.addFooterBtn('Dangerous action !', 'tingle-btn tingle-btn--danger', function() { 34 // here goes some logic 35 modal.close(); 36}); 37 38// open modal 39modal.open(); 40 41// close modal 42modal.close(); 43 44</script>
HTML
1<font> 2<div style="padding:0px 30px 30px 20px " "margin:10px 20px 10px 10px"> 3<textarea rows="3" cols="30" wrap="hard" 4 style="width:300px;height:100px;border-style:none;font-size:x-large;text-align:center;" 5 placeholder="Input your message!" 6 onchange="Limit(event)" onkeyup="Limit(event)"id="ttttt" > 7</textarea> 8</div> 9</font>
※質問と関連した部分のみ抜粋しています。
回答2件
あなたの回答
tips
プレビュー