开发者

I have one Textbox and inside the textbox i want the text which user cannot be deleted

开发者 https://www.devze.com 2022-12-28 12:12 出处:网络
i have one text box in which the text i开发者_高级运维nside the text box should not be deleted and after the text only the cursor has to be placed

i have one text box in which the text i开发者_高级运维nside the text box should not be deleted and after the text only the cursor has to be placed

Ex: For the textbox: "http://" should be available and the text which is in quotations cannot be deleted inside the textbox and the cursor should be after the quotations.

Thanks in advance, Vara Prasad.M


add this to the input field:

onchange="testEdit(this)"

and have a javascript function that does something like this:

function testEdit(field) {
  if (field.value.substring(0, 8) != "http://") {
    field.value = "http://" + field.value.substring(8);
  }
}

However, this is sloppy. The best way is to put the http:// in a label OUTSIDE the text box. If something is in a text box, it should be input. By putting that inside the text box, you will be confusing your users.

Good luck.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号