JSFiddle - React, Tailwind, and code Playground
HTML
<form>
<label>Ввести свою цену <input type='checkbox' id = 'setprice'></label>
<input id = 'price' style = 'display: none'><br>
<hr>
<input id = 'print' style = 'width: 100%' value = 'Добрый день, у нас есть 1020 долларов и мы хотим участников ближе к Москве'>
</form>
JavaScript
var defVal = $('#print').val();
$('#setprice').change(function() {
if ($(this).attr('checked')) {
$('#price').css('display', 'block');
} else {
$('#price').css('display', 'none');
$('#print').val(defVal);
}
});
$('#price').keypress(function() {
setTimeout(function() {
if ($('#price').val()) {
$('#print').val($('#print').val().replace(/\d+/, $('#price').val()));
} else {
$('#print').val(defVal)
}
}, 100)
});