1

I have an Angular2 application with PrimeNG suite installed.

I need to implement a form with two input elements and use in order to manage two date values.

I tried to use InputMask applying a specific mask and it works, now I don't know how to covert the date from Italian format ( provided by the user ) to TypeScript/Javascript format in order to be able to post the data...

The code I have implemented is this:

<p-inputMask mask="99/99/9999" [(ngModel)]="offert.dateDelivery" formcontrolname="dateDelivery" placeholder="dd/mm/yyyy" [ngModelOptions]="{standalone: true}" slotChar="dd/mm/yyyy"></p-inputMask>

The property offert.dateDelivery binds a Date field of a class.

The problem is that the user is forced to insert the value in Italian format ( dd/mm/yyyy ) that is actually not acceptable as date from Javascript/Typescript function...

How can I manage this scenario ?

thanks

3
  • 1
    so the user inputs this string 22/05/2009 and that works fine but you need to convert the string 22/05/2009 to a javascript Date object? or do you need to convert it to a very specific format ? Commented Apr 28, 2017 at 18:27
  • yes bro, that is what I need Commented Apr 28, 2017 at 18:34
  • click on the PrimeFaces tag in your question. Read it... are you using that? And no need to add relevant tags in the title Commented Apr 28, 2017 at 20:38

1 Answer 1

2

I solved the problem by binding two different independents string variables and parsing them to the two date properties after user click... The solution is easiest than expected

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.