web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

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

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Suggested answer
    Haansi Profile Picture
    1,433 Moderator on at

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans