How do I make a text input non-editable?
<input type="text" value="3" class="field left" readonly>
No styling necessary.
See <input>
on MDN https://developer.mozilla.org/en/docs/Web/HTML/Element/input#Attributes
How do I make a text input non-editable for a part of it?
You can capture the keyup
and blur
(in case user directly copy paste the value in textbox) event
function handleEv( event )
{
var thisObj = event.currentTarget;
var fixedValue = thisObj.getAttribute( "data-fixedvalue" );
if ( thisObj.value.indexOf( fixedValue ) != 0 )
{
console.log(thisObj.value, fixedValue);
event.preventDefault();
thisObj.value = fixedValue;
}
}
Demo of sample implementation
var el = document.querySelector( ".telinfo" );el.addEventListener( "keyup", handleEv);el.addEventListener( "blur", handleEv);
function handleEv( event ){ var thisObj = event.currentTarget; var fixedValue = thisObj.getAttribute( "data-fixedvalue" ); if ( thisObj.value.indexOf( fixedValue ) != 0 ) { console.log(thisObj.value, fixedValue); event.preventDefault(); thisObj.value = fixedValue; }}
<input type="text" value="+98912314789" class="telinfo" data-fixedvalue = "+9891">
How can I make a text input non editable with React?
The answer you used is non-normative.
Instead of using
... readonly>
use the more common HTML syntax as follows:
readonly='readonly'
and then pick one of the many ways to implement in react / JSX.
Kivy: how do I make a non-editable text input?
The readonly
property is your friend
TextInput:
id:out
background_color: (0, 0, 0, 1)
foreground_color: (0, 1, 0, 1)
multiline: True
text:""
readonly: True
How do I make a text input non-editable and secure?
No there is not. The user can send any GET and POST variables he wants. You have to validate the user input in your php script (I assume you use php because of the used tags)
Related Topics
Balanced Text Wrapping in HTML
Arrange 2 Items Per Row Using Flexbox
CSS Grids: Align Square Cells with Container Edges with Consistent Grid Gap
How to Set A:Link Height/Width with CSS
After Pseudo Element Not Appearing in Code
How to Color Table Columns Using CSS Without Coloring Individual Cells
How Could I Play a Shoutcast/Icecast Stream Using HTML5
Why Does Angularjs Ng-View Not Work Locally
How to Align a Label and a Textarea
Link External CSS File Only for Specific Div
Responsive Square Divs Cross Browser Compatible
How to Change Font Size in a Textbox in HTML
Excel Crashes When Attempting to Inspect Dispstaticnodelist
Why Does HTML5 Recommend Putting The Code Element Inside Pre
How May I Align Text to The Left and Text to The Right in The Same Line
Controlling The Size of an Image Within a CSS Grid Layout
Assign Variables to Child Template in {% Include %} Tag Django
How to See Which Srcset Image a Browser Is Using with Browser Developer Tools