document.addEventListener("DOMContentLoaded", function () {
    const inputs = document.querySelectorAll(
        "#pH-field, #ketinggian_tempat-field",
        "#ketersediaan_air-field",
        "#curah_hujan-field"
    );

    inputs.forEach((input) => {
        input.addEventListener("input", function () {
            this.value = this.value.replace(/[^0-9.]/g, "");
            this.value = this.value.replace(/^(\.)/, "");
            if ((this.value.match(/\./g) || []).length > 1) {
                this.value = this.value.substring(
                    0,
                    this.value.lastIndexOf(".")
                );
            }
        });
    });
});
