Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to set a custom error message to a form in angular

<span
      *ngIf="
        !loginForm.get('email')?.valid &&
        (loginForm.get('email')?.touched || loginForm.get('email')?.dirty)
      "
    >
      {{
        loginForm.get('email')?.hasError('required')
          ? 'Username Required'
          : loginForm.get('email')?.getError('invalid')
      }}

</span>
 this.loginForm.get('email')?.setErrors({ invalid: 'Invalid Username' });
Comment

how to set a custom error message to a form in angular

<span
      *ngIf="
        !loginForm.get('email')?.valid &&
        (loginForm.get('email')?.touched || loginForm.get('email')?.dirty)
      "
    >
      {{
        loginForm.get('email')?.hasError('required')
          ? 'Username Required'
          : loginForm.get('email')?.getError('invalid')
      }}

</span>
 this.loginForm.get('email')?.setErrors({ invalid: 'Invalid Username' });
Comment

PREVIOUS NEXT
Code Example
Javascript :: firestore get first document in collection and delete it 
Javascript :: Print Files with React 
Javascript :: on device size changes react-multi-carousel items not showing 
Javascript :: counter pluse and minus one javscript 
Javascript :: how to manually sort array javascript 
Javascript :: splice javascript list 
Javascript :: how to store data in cookie in javascript 
Javascript :: Replacing If Else Chains with Switch 
Javascript :: python to javascript code converter 
Javascript :: can javascript sort thai value 
Javascript :: set npm push proxy 
Javascript :: class validator validate form data 
Javascript :: nodejs how to beautify mysql arrays 
Javascript :: how to import images from public folder in react js 
Javascript :: &amp;&amp; in react jsx 
Javascript :: complite nodejs remove ubuntu 
Javascript :: regex placa de carro 
Javascript :: re-resizable react example 
Javascript :: owl get parent state 
Javascript :: discord.js Function to replace certain characters with a pattern 
Javascript :: Constructor can also be written like this 
Javascript :: JS time set 24H so AM PM tag 
Javascript :: no display after adding vue router 
Javascript :: netsuite get search column value suitescript 
Javascript :: Scale to fit 
Javascript :: concat vs spread 
Javascript :: React clock via props 
Javascript :: linux Error HH604: Error running JSON-RPC server 
Javascript :: javascript call example 
Javascript :: symfony iterate over entity 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =