XRule

Localize Messages

Put localized message text.

Following example shows how to localize messages. There are 3 predefined rules named 'req', 'num' and 'gt'. Their default message text was in English but now it works in Japanese.

<script>
    xr.put("req", "必須入力です");
    xr.put("num", "数字のみを入力してください");
    xr.put("gt", "{1}より大きな値を入力してください");
</script>
<form onsubmit="return xr(this)">
    <input data-xr="req()">
    <input data-xr="num()">
    <input data-xr="gt(20)">
    <input type="submit">
</form>

Let's test how it works.

Demo