CSS format special content in TextBox - html

I have a Textbox:
Now i want to highlight specific characters in this textbox with a colour. (for example "Text")
Is this possible?

Use ajax/jQuery for highlighting particular selected words in a textarea while writing words.
Check this link- http://bytes.com/topic/javascript/answers/820173-highlighting-searched-word-text-area

There is another way without using Javascript to place a text on a textbox. But the text will be ash all the time. There is a tag name "placeholder" on HTML. That may help
<input type="text" placeholder="text" name="inputbox">

Related

Format the display of a field

I'm aware that parsing numbers with pure CSS is impossible. But as in my case I know for certain that the input will always be in a specific way, is it possible to change the display of an input field based on the count of characters in it?
e.G. I want '123450' to be displayed as '1,234.50' - or if it were 'abcdef' it should become 'a,bcd.ef'.
So, I would like a rule that says: from right to left: after the second char display a dot, after the fifth and eight char display a comma.
Is that possible?
Example:
<input type="text" class="unformatted" value="123456" />
Should display like
<input type="text" class="formatted" vaulue="1,234.56" />
while still retaining its original value 123456.
What you're asking is not possible with pure CSS. The smallest you can go with CSS is the single HTML tag, you cannot go deeper than that.
Individual lines of text cannot be selected or altered, as they are seen as a whole by CSS engine.
With a little help from JavaScript, however, this can be easily done.

Storing English and corresponding Arabic to data base

I want to create a simple html form. Form contain two text box. First one is for typing in English and the second for the corresponding Arabic. How can I do that?
Thanks in Advance.
I want to type both English and Arabic without changing keyboard like google translator.
<form>
<input>
<input dir="rtl">
</form>

Model variable not showing initial space

Hi I have a model variable "name", which is binded to a span like
<input type="text" ng-model="name">
<span ng-bind="name"></span>
What my requirement is that to show up the text that are entered in the input field without eliminating any spaces.
I find a way to achive that by writing a css property
.allow-spaces{
white-space:pre;
}
so now if I enter a value "hello ooo buddy" it will show up exactly same in the span as well, but it will not show spaces at the begining like " hello buddy" is shown as "hello buddy". Please suggest me a solution for this.
ngModel by default trims beginning and trailing white spaces in input[type=text]. To disable this behavior write ng-trim=false in the input element.
Reference

Static placeholder for input

I don't know what will be the correct title for this question. I have inputbox with 'static placeholder', example for url jsfiddle.net/manyahin/MxRqX
<div class="controls">
<input type="text" />
<span>http://</span>
</div>
User can't delete http:// and type text after this. Span have margin-left: minus for position above input, and input have text-ident for get free space for span.
When I click at input, cursor set in start of input, before http. And when I start typing, cursor go to normal position. How to fix this bug or please give me an alternative method to make this happen. Sorry for my bad english.
If the input text always needs to start with http:// the easier way would be to put it as a label before the field rather than in it and then prepend the http:// on the backend. or you could catch it on the back end and read the text from the input field and prepend http:// to the input text if the user didn't enter this.
another way would be through jquery where you can set the value of the text box to be http:// with whatever text the user inputs.
A third less elegant way is to use two input fields and use css to position and style them to appear as one. set the first field value to http:// (assuming it is always going to be http://) and set it to readonly.
How about using :before in css?
Give this a go....
http://jsfiddle.net/MxRqX/3/

<input> multi-line capable via CSS

Is there a way to get an <input />-field in HTML to wrap lines if the text is longer than the field using CSS? I don't want to use <textarea /> as I want to avoid users entering hard line-breaks by pressing enter.
No, sorry. <input type=text> is single line by definition. See the W3C document Forms in HTML Documents:
text
Creates a single-line text input control.
Using Dojo's Dijit TextArea form control, based off TextArea, you can have an input field which begins as a single line and expands as the user adds to it.
See its documentation.
You can't do what you want with CSS alone, but you could use JavaScript to prevent the user from entering line breaks in a <textarea> field.
Look at this,
http://www.echoecho.com/htmlforms08.htm
The wrap options are the most tricky part of text areas.
If you turn wrap off the text is handled as one long sequence of text without linebreaks.
If you set it to virtual the text appears on your page as if it recognized linebreaks - but when the form is submitted the linebreaks are turned off.
If you set it to physical the text is submitted exactly as it appears on the screen - linebreaks included.
Your best bet is use a textarea (with autogrow capabilities if you like), and then strip out the new lines when the form is submitted. Using php it would be something like this:
$text = str_replace(array("\n","\r"),'',$_POST['text_field']);
This would have the desired effect of blocking newline characters. As others have pointed out it's not really possible to get multi-line input in an input field.