The DatePicker example included in Mi-Forms Designer installer offers a good solution in working with dates in VB. However, there is a growing need to accommodate forms that are web based, especially those intended for iOS and Android devices. Thus, we need to offer similar solutions in Javascript 


 Below is an the javascript code used to set the date of a field when a user clicks a hotspot button. Notice that on the javascript side, we need use the forms global MFAfterInkAdded function, passing in the fieldName as a parameter. We then check for the name of the field in the parameter and act accordingly. This example form has been attached as well.

// Triggered when a field gains ink
function MFAfterInkAdded(fieldName) {

	if (fieldName == "hsSetDate") {
		
		if (_form.getValue('tfDateField') == '') {
			_form.setValue('tfDateField', (new Date()).toLocaleDateString());
			
		} else {
			alert("The Date field has already been set!")
		}
	}
}