Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / Validation on key pres...
Finance forum
Unanswered

Validation on key press in form string control(existing form)

Posted on by 36

Dear Guys,

I need a validation method to be done when a key pressed on a text field in a form. This is used for tracking number in edit packingslip form.No action done, while on key press . When we moves the pointer from that field to another then only the validation starts. Without using any tab or enter, while we hit any key, the validation should be active. Pl. give me the solutions.

 

Here is my code for your reference.

 [FormControlEventHandler(formControlStr(CustPackingSlipJourEdit, CustPackingSlipJour_ShipCarrierWaybill), FormControlEventType::Validating)]
    public static void CustPackingSlipJour_ShipCarrierWaybill_OnValidating(FormControl sender, FormControlEventArgs e)
    {
        FormRun              formRun;
        FormStringControl    fsc;
        //int                strlen; 
        //int                startPosition;
        formRun = sender.formRun() as FormRun;
        fsc = sender.formRun().design().controlName(formControlStr(CustPackingSlipJourEdit, CustPackingSlipJour_ShipCarrierWaybill));
        str controlValue = fsc.text();              
        TextBuffer txt = new TextBuffer();
        txt.setText(controlValue);
        txt.regularExpressions(true);
        if(!txt.find("^[0-9]+$"))
        {
            throw error("@DT:TrackingNumber");
        }        
     
    }

Thanks in Advance,

Prasad N.

  • PN-21051232-0 Profile Picture
    PN-21051232-0 36 on at
    Validation on key press in form string control(existing form)
    Hi Andre,
     
     
    Yes i am using D365 F&O.
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 287,696 Super User on at
    Validation on key press in form string control(existing form)
    Hi Prasad,

    Can you confirm if you are using Dynamics 365?
  • Martin Dráb Profile Picture
    Martin Dráb 225,490 Super User on at
    Validation on key press in form string control(existing form)
    Moved from Dynamics AX forum.

    I suspect this isn't supported in F&O.
  • PN-21051232-0 Profile Picture
    PN-21051232-0 36 on at
    Validation on key press in form string control(existing form)
    Hi Andre,
     
    Thanks for the reply ,but i want this functionality in existing form control. There is no text change method .
    How i will do can i create the extension class for that method.
    could you please post sample code for that .
     
     
     
    Thanks & regards,
    Prasad N.
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 287,696 Super User on at
    Validation on key press in form string control(existing form)
    Hi Prasad,
     
    What version of Dynamics are you using? It is correct that the OnValidation will be called when leaving the field. Then it knows the complete string and can validate it as a whole. In case you want to act during typing, you can try to override the form control method TextChange.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans