I have a select list when i select the 'phone number' option i set regExp option in the number field so the user must enter a phone number in the required format. I also have an 'email' option in he select list and when selected i want to set the data-dojo-props for the number field.
In other words i am using one validationTextField to caputre both phone numbers and email address. However when the regExp is set it does not take the required effect and when the data-dojo-props is set for email it does not take the required effect. In both options if a valid value is entered or an invalid value is entered the validator does however show an error (red exclamation mark on field).
Code
<input type="text" required="true" name="contactString"
id="contactStringId" placeholder="Your Contact Number"
data-dojo-type="dijit/form/ValidationTextBox"
missingMessage="Please Enter Your Contact Number"
title="Contact Number / Email Address :" style="width: 25em;"/>
if (contactType.match(/^email|e-mail|mail.*$/)){
dijit.byId('contactStringId').attr('invalidMessage', 'Invalid ' + contactType.toProperCase() +' Format: [email protected]');
dijit.byId('contactStringId').set('data-dojo-props', 'validator:dojox/validate/isEmailAddress');
console.log('email settings set');
}else if(contactType.match(/^cell|home|work|fax|office.*$/)){
dijit.byId('contactStringId').attr('invalidMessage', 'Invalid ' + contactType.toProperCase() +' Format: (xxx)-xxx-xxxx');
dijit.byId('contactStringId').set('regExp', '^[0-9]\d{2}-\d{3}-\d{4}$');
console.log('phone number settings set');
}