Important Update: Community URLs redirect issues are partially resolved. Learn More. .

cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Object for stop user from enter non-domain email ID address in a text field

KunalGandhi
Contributor III

I have a requirement where user should get warning message whenever he enters an email ID which is not as per our company's domain.For example:- A company has email address ending with  @abc.com and if user enters any other address,he should get pop-up message or on save that this ID is not allowed.
Anybody has any code which relates  to  this requirement.  @DavidPetty @Ilya 

5 REPLIES 5

I want to stop a user from entering an non-organizational email address by validating its domain like @abc.com.If it is not @abc.com,warning message should appear. Any custom object available for it. @Anonymous 

Anonymous
Not applicable

Yes, and that is exactly regexp I provided in the 1st post. You just need to change and provide your regexp and field id to the one of custom object examples.

Hi,

I created this custom object by referring your 1st post .Warning message is appearing when user is enter non-domain email address but still user is able to save or save and close the record. How to give warning on save or save and close as well. Any code reference for the same. @Anonymous  @DavidPetty  Below is the code which I created

Custom Code to stop entering Non-Domain email address in certificate request application

<script type="text/javascript">
function pageLoad() {

// Using the .focusout event causes the warning to display only once.
$('input[id*="f23172c"]').focusout(function() { IsEmailValid("f23172c", $(this).val()); });
$('input[id*="f23173c"]').focusout(function() { IsEmailValid("f23173c", $(this).val()); });
$('input[id*="f23171c"]').focusout(function() { IsEmailValid("f23171c", $(this).val()); });
$('input[id*="f23169c"]').focusout(function() { IsEmailValid("f23169c", $(this).val()); });
$('input[id*="f24115c"]').focusout(function() { IsEmailValid("f24115c", $(this).val()); });
$('input[id*="f24116c"]').focusout(function() { IsEmailValid("f24116c", $(this).val()); });
$('input[id*="f24112c"]').focusout(function() { IsEmailValid("f24112c", $(this).val()); });
$('input[id*="f24114c"]').focusout(function() { IsEmailValid("f24114c", $(this).val()); });

// Using the .change event causes the warning to display twice.
//$('input[id*="f23172c"]').focusout(function() { IsEmailValid("f23172c", $(this).val()); });
//$('input[id*="f23173c"]').focusout(function() { IsEmailValid("f23173c", $(this).val()); });
//$('input[id*="f23171c"]').focusout(function() { IsEmailValid("f23171c", $(this).val()); });
//$('input[id*="f23169c"]').focusout(function() { IsEmailValid("f23169c", $(this).val()); });
//$('input[id*="f24115c"]').focusout(function() { IsEmailValid("f24115c", $(this).val()); });
//$('input[id*="f24116c"]').focusout(function() { IsEmailValid("f24116c", $(this).val()); });
//$('input[id*="f24112c"]').focusout(function() { IsEmailValid("f24112c", $(this).val()); });
//$('input[id*="f24114c"]').focusout(function() { IsEmailValid("f24114c", $(this).val()); });
}

function IsEmailValid(field, str){
var myRegExp = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@(pwc.com)$/;
if(myRegExp.test(str) != true && str != "") {
setTextField(field, "");
WarningAlert('The field must contain RIL domain email address only. Bad value: ' + str, 'Warning');
}
}

function setTextField(f,v) {
var textFieldAttributes = new Array();
textFieldAttributes.push({
enabled: true,
emptyMessage: '',
validationText: v,
valueAsString: v,
lastSetTextBoxValue: v});
var textFieldAttributesSerialised = Sys.Serialization.JavaScriptSerializer.serialize(textFieldAttributes[0]);
$('input[id$="'+ f +'c"]').val(v);
$('input[id$="'+ f +'c_ClientState"]').val(textFieldAttributesSerialised);
}
</script>

Anonymous
Not applicable

You need to override handler for save buttons. Look at @DavidPetty code in here for hijacking save buttons:

https://www.archerirm.community/t5/archer-custom-objects-forum/listing-users-from-a-record-permissions-field-with-a-custom/td-p/679482