Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

This question related to the PCF (Power component framework) Password Validation

Posted on by Microsoft Employee

I need to be Create one form using PCF in that some password validation i need to give but i write code in index.ts file it showing error

Suggest:-  Kindly provide me Code where i have to mentioned the validation code

plz check my below code :-

import {IInputs, IOutputs} from "./generated/ManifestTypes";

export class ValidPass implements ComponentFramework.StandardControl<IInputs, IOutputs> {


/** variable for HTML elements */
private _FormElement: HTMLInputElement;

private _submitButton:HTMLElement;
// private _PasswordCheckLabel:HTMLElement;

/** variable for Form Properties*/
private _UserId: string;
private _Password:string;
private _PasswordCheck:string;

/** event variables */
private _submitClicked:EventListenerOrEventListenerObject;
// private _PasswordCheckOnKeypressed:EventListener;


private _context: ComponentFramework.Context<IInputs>;
// private _notifyOutputChanged: () => void;
private _container: HTMLDivElement;

constructor()
{

}

/**
* Used to initialize the control instance. Controls can kick off remote server calls and other initialization actions here.
* Data-set values are not initialized here, use updateView.
* @param context The entire property bag available to control via Context Object; It contains values as set up by the customizer mapped to property names defined in the manifest, as well as utility functions.
* @param notifyOutputChanged A callback method to alert the framework that the control has new outputs ready to be retrieved asynchronously.
* @param state A piece of data that persists in one session for a single user. Can be set at any point in a controls life cycle by calling 'setControlState' in the Mode interface.
* @param container If a control is marked control-type='starndard', it will receive an empty div element within which it can render its content.
*/
public init(context: ComponentFramework.Context<IInputs>, notifyOutputChanged: () => void, state: ComponentFramework.Dictionary, container:HTMLDivElement)
{
this._context = context;
// this._notifyOutputChanged = notifyOutputChanged;
this._container = container;


this._submitClicked = this.submitClick.bind(this);
// this._PasswordCheckOnKeypressed = this._PasswordCheckOnKeypressed.bind(this);


this._FormElement = document.createElement("input");
// this._FormElement.addEventListener("check", this._PasswordCheckOnKeypressed);
this._FormElement = document.createElement("input");
this._FormElement.setAttribute("Value", "UserId");
this._FormElement.setAttribute("type","Password");
this._FormElement.setAttribute("lenght","PasswordCheck");

// this._FormElement.addEventListener("check", this._PasswordCheckOnKeypressed);

//this._PasswordCheckLabel = document.createElement("input");
//this._PasswordCheckLabel.setAttribute("Value","PasswordCheck");
//this._PasswordCheckLabel.setAttribute("type","PasswordCheck");
//this._PasswordCheckLabel.addEventListener("check",this._PasswordCheckOnKeypressed);

this._submitButton = document.createElement("input");
this._submitButton.setAttribute("Value", "Submit");
this._submitButton.setAttribute("Type","Submit");
this._submitButton.addEventListener("click", this._submitClicked);

//this._container.appendChild(this._FormElement);
this._container.appendChild(this._submitButton);
// this._container.appendChild(this._PasswordCheckLabel);
}


/**
* Called when any value in the property bag has changed. This includes field values, data-sets, global values such as container height and width, offline status, control metadata values such as label, visible, etc.
* @param context The entire property bag available to control via Context Object; It contains values as set up by the customizer mapped to names defined in the manifest, as well as utility functions
*/
public updateView(context: ComponentFramework.Context<IInputs>): void
{
// Add code to update control view
}

/**
* It is called by the framework prior to a control receiving new data.
* @returns an object based on nomenclature defined in manifest, expecting object[s] for property marked as “bound” or “output”
*/
public getOutputs(): IOutputs
{
return {

UserId:this._UserId,
Password:this._Password
};
}

/**
* Called when the control is to be removed from the DOM tree. Controls should use this call for cleanup.
* i.e. cancelling any pending remote calls, removing listeners, etc.
*/
public destroy(): void
{
// Add code to cleanup control if necessary
}

================== public submitClick(evt:Event): void ================
{
debugger;
var Password= this._FormElement;

// Validate lowercase letters

if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(this._FormElement.value))
{
alert("correct password")
}
else {

alert("You have entered an invalid email address!")
}
}

}

*This post is locked for comments

  • Suggested answer
    Haansi Profile Picture
    Haansi 1,431 on at
    RE: This question related to the PCF (Power component framework) Password Validation

    What error you are getting ?

    If I m understanding you correctly, you can add validation in "updateView".

    Alternatively you can add a JS event handler for your "input" and register a JS event handler may be something like "onblur" and do validation there.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans