{Validate} UID Validation


 

While Dealing with the forms which contains personal information of Person or contact, we have to write validations for the fields in which we want to take input from user.

1) UID Validation: –

UID is the Unique Identification Number Which is for Indian Citizen. When we use UID in the form then we have to write script for validating it.

Format of UID: -UID is 12-digit integer number

XXXX-XXXX-XXXX

Eg: -1234-5678-9012

JavaScript for UID Validation: –

Paste following Script in Web Resource and set Event OnChange

function UIDValidation()

{

var value = Xrm.Page.getAttribute(‘AttributeName’).getValue();

var pattern =/^\d{12}$/;

if(!value.match(pattern) )

{

alert(“Please enter numeric value only (enter your 12 digit UID number)”);

Xrm.Page.getControl(‘AttributeName’).setNotification(“Invalid UID number”);

Xrm.Page.getAttribute(‘AttributeName’).setValue(null);

return false;

}

if(value!=null)

{

var v1=Xrm.Page.getAttribute(‘AttributeName’).getValue().substr(0,4);

var v2=Xrm.Page.getAttribute(‘ AttributeName ‘).getValue().substr(4,4);

var v3=Xrm.Page.getAttribute(‘ AttributeName’).getValue().substr(8,4);Xrm.Page.getAttribute(‘ AttributeName ‘).setValue(v1+”-“+v2+”-“+v3);

Xrm.Page.getControl(‘ AttributeName ‘).clearNotification();

}

}

Hope it helps You!

Please get in touch with us at deepesh@marvels.company for any of your Dynamics 365 needs.