JSFiddle - React, Tailwind, and code Playground

by Vaibhav Mehta

HTML

<input type="text" />

CSS

input {
    outline: 0;
}

JavaScript

var regx = /^[0-9]{1,6}(\.[0-9]{1,5})?$/;

$('input[type=text]').on('input', function() {
    if(regx.test($(this).val())) {
        $(this).css('border', '1px solid green');
    } else {
        $(this).css('border', '1px solid red');
    }
});