In my template driven form the textarea is required based on a condtion. I would also like the pattern to be conditional. I tried this syntax based on a question from angular 1.x but it doesn't seem to work. - pattern=" condition ? '.*[^ ].*' : ''" I also tried - pattern="condition ? (\s*[^\s]+\s*)+ : .*". is this possible with the later versions of Angular? Here is my stack blitz: https://stackblitz.com/edit/conditionalpattern
Conditional pattern to be used along with required Angular7/8
2.4k views Asked by Flash At
2
There are 2 answers
Related Questions in HTML
- How to store a date/time in sqlite (or something similar to a date)
- How to use custom font during html to pdf conversion?
- Storing the preferred font-size in localStorage
- mp4 embedded videos within github pages website not loading
- Scrimba tutorial was working, suddenly stopped even trying the default
- Is there any way to glow this bulb image like a real light bulb
- With non-graphical maps in Leaflet, zoomDelta doesn't work
- What can I do to improve my coding on both html and css
- Uncaught TypeError: google.maps.LatLng is not a constructor at init (script.js:7:13)
- Bootstrap modal not showing at the desired position on a web page when the screen size is smaller
- Displaying a Movie List on a Website Using Jinja2 and Bootstrap
- How to redirect to thank you page after submitting a Google form embedded into a Google Site?
- Storing selected language in localStorage
- Fences (parenthesis, braces) in HTML and MathML
- Understanding Scroll Anchoring Behavoir
Related Questions in ANGULAR
- Firebase link existing user to anonymous account?
- It doesnt always show all the books on my homepage
- Google adsense ads.txt status cannot be not found
- When I navigate to the URL'http://localhost:4200/', it redirects me back
- Ionic Angular Standalone ion-icon are not showing at all
- How to make Angular understand that view child is of a specific type, not a general ElementRef?
- vscode, debug angular, first time, doesn't debug, 2nd time stops at main.js then it's ok
- How to perform CRUD operations on a static JSON array in Angular? (without API)
- Ngrx props<>() method in createAction()
- How to animate rotation of an image inside input control?
- Detecting click inside and outside of the listening component in Angular
- Angular - type guard not narrowing types
- In node_modules file i am getting Angular genric error while using fontawesome in angular12
- Angular 16 sending null values to API
- GoogleCloud Error: Not Found The requested URL was not found on this server
Related Questions in VALIDATION
- Terraform valdiate that one of N variables is set to "true"
- How to validate if Confirm Password is same or not with the Password in React Native using ValidateJS?
- How to create yup schema for dynamic array of different objects
- Quintic Number Number Counting Hash Function
- DropdownButtonFormField doesn't apply custom InputDecoration style
- Is there a way to set a cells value based on the value this cell held at a certain time, even when the cell value changes over time?
- Multiple regex expressions to check mobile number in javascript
- Java Pojos - Setter-Call (Field Touched) Detection
- Input Field Required
- Angular restore ngModel input field to it's previous value
- Bean Validaton : org.springframework.web.bind.MethodArgumentNotValidException
- javax validation not working on spring boot
- How to show warning message for unmatched confirm password
- Flutter TextFormField validation with Firestore
- eval_set in CatBoostRegressor
Related Questions in NG-PATTERN
- Angularjs: Validation for Mac address not working
- regex look-behind expression incompatibily with IE
- ng-pattern for PCRE
- Angular js form validation without html form
- How to disallow space using ng-pattern
- ng-pattern does not work when pattern set dynamically in ng-repeat
- ngPattern for validatin a String
- Browser hangs while using ng-pattern in angularjs
- Regex empty string or number
- To allow only one numeric value in text box based on regular expression in AngularJs
- Conditional pattern to be used along with required Angular7/8
- AngularJS:ng-pattern has no effect preventin non numeric userinput in input-field
- How to allow only three numbers before a decimal point and two numbers after it. Is there a regex for this?
- Add another regex to an existing one
- How can ng-pattern be not triggered when the field is pristine?
Related Questions in NG-REQUIRED
- required directive not working on select tag in Angular
- AngularJS ngRequired custom directive
- Conditional pattern to be used along with required Angular7/8
- Custom Angular Validation based on a selection radio select button
- myForm.$valid returns true even though required feld is empty
- md-select and required doesn't detect empty value
- Angularjs - ng-invalid not working correctly on select element inside ng-repeat table
- ng-required doesn't work properly
- Angular ng-required
- How implement dynamic required for ng-repeat in angularjs?
- angularjs ng-repeat input fields ng-required not working
- apply ng-required if another element is selected
- How to reset the value of validation error based on radio button
- Angular2 <form> input validation
- Refuse space only input with ng-required
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
I think if you want to pass an expression, you should wrap pattern in square brackets. But more importantly, you cannot use the attribute
patternin the tagtextarea, becausepatternis not an allowed attribute fortextarea.As described in MDN Web Docs,
So in your case I would either use an
inputor consider using aCustomValidator. If you use an input, make sure to wrap the expression in brackets:Here's a tiny stackblitz with a working example of an input field.