Click here to Skip to main content
15,997,856 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
textbox.SelectAll();
textbox.SelectionStart = 0;


as i am using this in my code.
for the purpose when my client click on text box at that time select all text and when he press 123 etc then it type there.
by default there is 0.00 in my text box.

so how can i write
VB
textboxId.SelectAll();
textboxId.SelectionStart = 0;


in my javascript function.
Posted

1 solution

<input type="text" onfocus="this.select()" onMouseUp="return false" />

or :

XML
<script type="text/javascript">
    function selectAll(id) {
        var textBox = document.getElementById(id);
        textBox.select();
        textBox.readOnly = true;
        textBox.onmouseup = function() {
            textBox.select();
            return false;
        };
        textBox.onmousedown = function() {
            textBox.select();
            return false;
        };
    };
</script>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900