Input text field not displaying the value inside the "quotes" - javascript

From the asp.net MVC project: I have an input text field, and its value should comes from database. But the text inside the quotes has been prevent from value.
Sample text: Some text "150"
But it render as: <input type="text" id="" value="Some text" "150">
I need to display complete text inside the quotes as input value that comes from database..!

If you are using asp.net MVC, use #Html.Raw()
If it is plain HTML then you can combine single with double quotes.
ex.
<input type="text" id="" value='Some text"150"'>
If you need a precise answer then you need to specify how your UI is being rendered.

Related

value attribute in hbs not showing string after space

<input type="text" class="form-control" id="exampleInputEmail2"
name="productName" value={{product.productName}} >
Inside my product.productName = Smart Phones, but it only shows 'Smart' inside the input field
How to show may whole string in my input field in HBS
Please provide quotes for the value. I think this will help you to figure out the error:
eg:
value="{{product.productName}}"

Input value attribute not showing full text on search bar

My code is a web application using Flask (python) framework, I have this search bar implemented on HTML5 and I want the text inputted for search to appear on the search bar after the page loads; like this (where {{query}} is a variable passed on by Jinja2):
<form class="search-bar search_header" method="GET" action="/">
<input class="search_input" name="q" tabindex="1" type="text" value={{query}}>
<button class="search_button" tabindex="2" type="submit">
<i class="icon-search"></i>
</button>
</form>
The problem is that only the text up until the first white space is displayed, the rest is cutoff, so "This is an example" will display "This" in the search bar. If I pass on a regular string instead of the variable then it works fine.
{{query}} is of type unicode, if that matters, and I have tried formatting it in several ways to no avail, is there any workaround to this?
I have also thought about saving the variable as Javascript from the landing page search bar html, but I am new at Javascript, any suggestions would be highly appreciated!
I expect you have to wrap the placeholder in double quotes:
<input class="search_input" name="q" tabindex="1" type="text" value="{{query}}">
Otherwise the substituted html code would be
<input class="search_input" name="q" tabindex="1" type="text" value=text with whitespace>
The commonplace html renderer would parse this into an input element with attributes value, with and whitespace, the latter two coming without a value while value's value would be text. Note that most html renderers are tolerant against attributes which are undefined and value-less attributes are covered by the standard (as it is to omit the double quotes).

Angular JS getting a value to appear in an input text

I have this value here:
{{step1.$valid}}
which returns false. What I am trying to do is get the text "false" to appear in an input text box:
<input type="text" ng-model="user.stepValidation" ng-value="{{step1.$valid}}"/>
I have also tried value and ng-bind and neither of these get the value from {{step1.$valid}} to appear in my input text...please help.
Try this:
<input type="text" ng-model="user.stepValidation.step1.$valid"/>
Here's a Fiddle.

Form input showing image insted of text value

I have a form which i am using to update adds on my site, I am filling input value with existing adds but there is a problem in form it is showing adds images instead of text value.
I need to update adds link by replacing the link value in input field.
Input field has value as
<input name="addtop" type="text" value="<a href="http://www.xxyy.com/4g...." target="_blank" <img src="http://www.xxyy.com/h4...."/></a>" />
when i try to load page it shows image in input field instead of text as:
<a href="http://www.xxyy.com/4g...." target="_blank" <img src="http://www.xxyy.com/h4...."/> ></a>`
Please see how can I make input to show links in value instead of images.
You should use htmlspecialchars for whatever sets the value= of those <input type="text"> boxes.
It will take image tags and HTML and render them as HTML entities that will safely be place in that text box.
Then when you want to process the contents of that for, just use html_entity_decode to decode the HTML entities.
UPDATE: Your first attempt to fix this—shown in the comments—is this:
<input name="addtop" type="text" value="htmlspecialchars(<?php echo $addtop?>)" />
That is just incorrect. htmlspecialchars is a PHP function. So you need to put it in the <?php … ?> area. It should be:
<input name="addtop" type="text" value="<?php echo htmlspecialchars($addtop)?>" />

HTML: text input is not being submitted

I have an HTML form with many fields, including a text field, that is,
<input name="my_field" type="text"></input>
Now, this text field is being changed by tons of JavaScript, jQuery and CSS code. The result of all this interaction is that when the form is submitted, this particular text field simply gets ignored (it is like that field was not there). I am not saying it get submitted with empy text, it simply doesn't appear in the list of fields submitted...
Because there are tons of code affecting this particular text field, I don't know what is causing this weird behavior. So I was wondering if someone could tell me what kind of HTML attribute (or JavaScript code, or jQuery code, or ...) could result in a text field being ignored.
At the end of all this interaction, I get the following HTML code (retrieved using the "Inspect Element" from Chrome):
<input id="id_my_field" maxlength="200" name="my_field" type="text" class="tt-query" autocomplete="off" spellcheck="false" dir="auto" style="position: relative; vertical-align: top; background-color: transparent;" data-original-title="" title=""></input>
You should add a name attribute to the input:
<input type="text" name="myinput" />
Add the name attribute, like this:
<input name="myField" type="text"></input>

Categories