function onChange(control, oldValue, newValue, isLoading) { if (isLoading || newValue == '') { return; } //Type appropriate comment here, and begin script below var pattern = /^[(]?(\d{3})[)]?[-|\s]?(\d{3})[-|\s]?(\d{4})$/; if (!pattern.test(newValue)) { alert('Phone enter a valid phone number'); g_form.setValue('variable_name', ''); } }