How can I use ref in TextField

String refs are deprecated and material-ui does not support using them. I recommend reading: https://reactjs.org/docs/refs-and-the-dom.html Also to get a ref to the <input /> element you should use the inputRef prop. Read about it here. If your React is up to date you should use createRef or the useRef hook. Below are some examples // … Read more

Best way to restrict a text field to numbers only?

This is something I made another time for just numbers, it will allow all the formatters as well. jQuery $(‘input’).keypress(function(e) { var a = []; var k = e.which; for (i = 48; i < 58; i++) a.push(i); if (!(a.indexOf(k)>=0)) e.preventDefault(); });​ Try it http://jsfiddle.net/zpg8k/ As a note, you’ll want to filter on submit/server side … Read more

How to set focus to an iOS text field?

Make the textField the first responder; this will also popup the keyboard: [self.textField becomeFirstResponder]; And just some more typical example code which may help someone, in your storyboard, click on one of the text fields, and set the outlets-delegate to be the class in question. In that class, in the .h file make sure that … Read more

Change the default border color of TextFormField in FLUTTER

Use enabledBorder of the InputDecoration, don’t forget you can also use the focusedBorder, like this : InputDecoration( labelText: “Enter Email”, fillColor: Colors.white, focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(25.0), borderSide: BorderSide( color: Colors.blue, ), ), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(25.0), borderSide: BorderSide( color: Colors.red, width: 2.0, ), ), ) Here you have more info: https://api.flutter.dev/flutter/material/InputDecoration/enabledBorder.html

How to expand a textField in flutter looks like a text Area

All you need to do is set the maxLines variable when creating a TextField. I have added the text field inside a Card widget so you can see the total area. @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(“Simple Material App”), ), body: Column( children: <Widget>[ Card( color: Colors.grey, child: Padding( padding: … Read more

In MUI when do we use Input vs. TextField for building a form?

For most use cases, you should use TextField rather than the lower-level components that it delegates to (such as Input). The relevant part of the documentation is here. Particularly this line: TextField is composed of smaller components ( FormControl, Input, FilledInput, InputLabel, OutlinedInput, and FormHelperText ) that you can leverage directly to significantly customize your … Read more

Hide textfield blinking cursor

The basic idea is, that the cursor’s color is the same as the text’s color. So the first thing you do is make the text transparent, thus taking the cursor away with it. Then you can make the text visible again with a text shadow. Use this link to see it live in jsfiddle. input[type=”text”]{ … Read more