I have a text area where I can enter a SQL statement. The text "SELECT TOP 1" is used at the begining of the sql statement as a default prefix that can not be removed.
In order to archive this functionality, I found three options:
1. Use an inputMask and build a pattern for the entered text. We can use the prefix inside the text area:
http://jsfiddle.net/SEXAj/2130/
2. Create an javascript event listener on event "input" and calculate to prevent the prefix is removed
http://jsfiddle.net/sarbbottam/TUc94/
3. Use another html tag like "div"/"span" that contains the prefix and calculate the suitable position
+ Tag "span": http://jsfiddle.net/4YzZy/
+ Tag "div": http://jsfiddle.net/215b34fs/
I chose the 3rd approach with tag "div" because it's the most easiest solution and suitable for me at that monment.
References:
[1]. http://stackoverflow.com/questions/24846041/how-do-i-add-a-default-text-to-the-beginning-of-an-html-text-area
[2]. http://stackoverflow.com/questions/24305200/how-to-enable-to-insert-spaces-in-masked-input-plugin-jquery-plugin
1. Use an inputMask and build a pattern for the entered text. We can use the prefix inside the text area:
http://jsfiddle.net/SEXAj/2130/
2. Create an javascript event listener on event "input" and calculate to prevent the prefix is removed
http://jsfiddle.net/sarbbottam/TUc94/
3. Use another html tag like "div"/"span" that contains the prefix and calculate the suitable position
+ Tag "span": http://jsfiddle.net/4YzZy/
+ Tag "div": http://jsfiddle.net/215b34fs/
I chose the 3rd approach with tag "div" because it's the most easiest solution and suitable for me at that monment.
References:
[1]. http://stackoverflow.com/questions/24846041/how-do-i-add-a-default-text-to-the-beginning-of-an-html-text-area
[2]. http://stackoverflow.com/questions/24305200/how-to-enable-to-insert-spaces-in-masked-input-plugin-jquery-plugin
Comments
Post a Comment