Clib.strpbrk()- Restricting user from entering certain Characters / Numbers into a field

Requirement: I am having a field of type ‘DTYPE_TEXT’ (For example ‘Email Address’ in ‘Contact’ BC). I should restrict the users from entering the numbers into ‘Email Address’  field.

Solution: Added following piece of code in ‘PreSetFieldValue’ event of ‘Contact’ BC.

function BusComp_PreSetFieldValue (FieldName, FieldValue)
FieldName = “Email Address”;
var rStrpbrk = Clib.strpbrk(FieldValue, “1234567890!”);
if(rStrpbrk != null)
TheApplication().RaiseErrorText(“Please do not enter numbers”);
return (ContinueOperation);

Explanation:  Whenever user tries to enter 1 or 2 or 3……or 0 into ‘Email Address’ field the above error message will popup.

Using Clib.strpbrk() function , we can restrict the user from entering special characters and characters as well.


Happy reading@Optanium!!!