Date of birth in 3 fields of user input

Hi,

I have a form created which feeds in to my database. I’d like to have a field for a date of birth without them having to select from a calendar where they have to scroll back by years. Can’t there just be a DD MM YYYY field where they can enter numbers for example?

I am new to this so maybe it exists but I can’t find it. Thanks in advance!

Best wishes
James

Hi James,

Sure :slight_smile:

You can, for example, add 3 text boxes, and use code to validate that there a valid input to it (e.g. month between 1 and 12, and the length of the text).
Just a small example, lets say I have a text input for months called ‘#month’, I would set an onChange event that will look like that:

export function input1_change(event, $w) {
	const newValue = $w('month').text;
	const valueAsNumber = parseInt(newValue, 10);
	if (valueAsNumber < 1 || valueAsNumber > 12) {
		//show some error here
	}
	//some more validations here...
}

You can also use Regular Expressions for validation.

You can also use just one text box, and force the format to look like you want, but I think that this will require some more coding (not too complex, just with a lot of invalid input cases to think about).

Hope this helps,
Liran.

Hey guys!