How to update a connected Field based on another Field in a Form with Javascript

How to update a Field based on another Field in a Form,
For example if i have a Field date and a connected Field date-range ( date-range is a table it self for sure) and i want to update date-range if the Field date in table one is between these two attributes date before and date after in table date-range.