LoginSignup
0

More than 5 years have passed since last update.

Riot.jsで簡単な入力値チェック

Posted at

はじめに

少量のコードで入力値チェックを実装したので備忘録として…

実装

これだけです。

test.tag
<test>
 <input onInput={check_num.bind(this,"num_fx")}>
 <input ref="num_fx" type="button" value="確定">
 <script>
    check_num(nm,e){
      var f = isNaN(e.target.value);
      self.refs[nm].disabled=f;
      self.refs[nm].value=f?"数値を入力してください":"確定";
    }
 </script>
<test>

個人的に嫌なところ
引数に対象としたい要素名を入れなければならないのが少し嫌…
あと、f?"数値を入力してください":"確定"も固定値なのが嫌…

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0