cjk-protector

    1.0.0 • Public • Published

    cjkProtector jQuery plugin

    Protect your inputs/textareas from Chinese, Japanese and Korean (CJK) characters.

    Build Status

    Usage

    <form>
      <div>
        <input type="text">
      </div>
      <div>
        <textarea></textarea>
      </div>
      <input type="submit">
    </form>
    $(":input").cjkProtector();

    Options

    errorClass (string)

    CSS class name added on input's wrapper div element when CJK characters are found.

    Default value is 'field_with_errors'

    $(":input").cjkProtector({
      errorClass: "cjk_error"
    });

    errorMessage (string)

    Error message displayed when CJK characters are found.

    Default value is 'Please use latin characters'

    $(":input").cjkProtector({
      errorMessage: "CJK characters found!"
    });

    onError (function)

    Called when CJK characters are found.

    Default value is empty

    $(":input").cjkProtector({
      onError: function() {
       console.log("CJK characters found!")
      }
    });

    onSuccess (function)

    Called when CJK characters disappear.

    Default value is empty

    $(":input").cjkProtector({
      onSuccess: function() {
       console.log("Valid characters!")
      }
    });

    Running specs

    First, you have to install all the project dependencies:

    $ npm install

    and then execute:

    $ grunt test

    Compile plugin

    Just execute:

    $ grunt build

    This will generate two versions of the plugin in the dist folder.

    Install

    npm i cjk-protector

    DownloadsWeekly Downloads

    2

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • peertransfer