JSFiddle - React, Tailwind, and code Playground

by Karthik Parthi

HTML

<input type="text" id="min_rent" name="min_rent" onkeypress="return isPrice(event,$('#min_rent').val())" >

JavaScript

function isPrice(evt,value) {
var charCode = (evt.which) ? evt.which : event.keyCode;
    if((value.indexOf('.')!=-1) && (charCode != 45 && (charCode < 48 || charCode > 57))){
		return false;
    }    
    else if(charCode != 45 && (charCode != 46 || $(this).val().indexOf('.') != -1) && (charCode < 48 || charCode > 57)){
		return false;
    }
    return true;
}