Attempting to generate a date using AngularJS, following the provided documentation.
Input with date validation and transformation. If the browser does not support HTML5 date input, a text element will be used instead. In this scenario, text should be entered in the valid ISO-8601 date format (yyyy-MM-dd), for example: 2009-01-06. Since some modern browsers do not yet support this input type, it's crucial to provide guidance to users on the expected input format via a placeholder or label.
The system only accepts dates in the valid ISO-8601 format (yyyy-MM-dd).
Attempted to specify a new date format in the attribute pattern
as demonstrated in the code snippet below:
<div ng-app="">
<form name="frmSPA" novalidate>
<input type="date" placeholder="Enter SPA Date" pattern="dd/MM/yyyy" name="SPADate" ng-model="SPADate" ng-required="true" />
<span ng-show="frmSPA.SPADate.$touched && frmSPA.SPADate.$error.required">SPA Date is required</span>
<span ng-show="frmSPA.SPADate.$touched && frmSPA.SPADate.$error.date">Not a valid date</span>
</form>
</div>
However, this approach was unsuccessful.
How can you modify the default date format to dd/MM/yyyy
? Here is the jsfiddle.