input和textarea标签的select()方法----选中文本框中的所有文本

JavaScript select()方法选中文本框中的所有文本

<input>和<textarea>两种文本框都支持select()方法,这个方法用于选择文本框中的所有文本

。在调 用select()方法时,大多数浏览器都会将焦点设置到文本框。这个方法不接受参数,可

以在任何时候调用。下面来看一个例子:

var textbox = document.forms[0].elements["textbox1"];
textbox.select();

在文本框获得焦点时选择其所有文本,这是一种非常常见的做法,特别是在文本框包含默认值

的时候。因为这样做可以让用户比比一个一个的删除文本。

再来看另一个表单校验的例子:

function checkData(str,id)
  {
    
   var obj =document.getElementById(id);
 
   if(obj.value=="")
   {
    alert(str+"不能为空!");
    obj.select();
    obj.focus();//获取焦点
    return false;
   }
   return true;
  }

if(checkData("用户名","userName") && checkData("登录名","loginName") )
  {
 …… 
  }

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
CuteEditor for ASP.NET文版是建立在Html基础之上,最简单易用、功能最强大的所见即所得Asp.net在线编辑器。 CuteEditor可以帮助Asp.net开发者轻松的对原来文本框(Textarea)的内容(包括文字、图片等Html内容)进行编辑,更重要得是这些内容编辑的实现是所见即所得方式。 CuteEditor还集成了文件(包括图片、文档等)上传、媒体(包括视频、声音等,支持YouTube)文件直接插入等对你来说非常实用的功能模块。 对于商业授权用户,他们以完全自己进行操作升级和安全维护,我们制定了多种授权方式供广大用户选择。 CuteEditor功能特点 是什么使CuteEditor成为Html在线编辑器的领航者?除了其强大的功能和方便的使用, 这里还有一些顶尖的技术因素是CuteEditor编辑器成为你编辑和发布Web内容的最佳选择: 跨浏览器、跨平台的所见即所得网页编辑器 Compatible with the most important browsers available in the market: IE 5.5+, Firefox 1.0+, Mozilla 1.3+, Netscape 7+, Chrome and Safari (1.3+). This includes Macintosh and Linux. 界面简洁加载速度快 Numerous optimization methods has been applied. It's clean, compact, extremely fast-loading, but still powerful and efficient. CuteEditor遵循Web标准,没有类似 这种标签 Does your online html editor still use deprecated tags such as <FONT>? Cute Editor will help you build sites that adhere to the latest HTML standards, generates clean HTML/XHTML code with no deprecated tags. 能自动清理HTML代码Word标记 When text is pasted from Microsoft Word allot of unnecessary word specific markup is carried across. This can result in web pages that take an unnecessarily long time to download. The Paste from Word button solves this by removing word markup before pasting the text into your page. 对于开发人员来说简单易用 The perfect addition to your content management system! Only a couple lines of code , you don't need to be an expert. Allows you to add an online HTML editing functionality that works with standard HTML form. 很容易用API隐藏按钮和Tabs标记 Cute Editor allows developers to set the image directory, set the controls width, disable image uploading and deleting, restrict access to the source/preview tabs, hide buttons and lists that you don't want your clients to see or access. 高级表格管理 Create and modify tables and table cells. Set their border color, alignment, cellspacing and more! Once you've created a table, simply right click inside of it and use the handy popup menu to change its attributes. <caption>,<summary>,<thead>,<tfoot>,<th> tags are supported. 图片插入和自动上传 Built-in thumbnail generator. Thumbnail images are dynamically created; Supports upload new images. Paging - specify how many images. Support auto resize images. 用模板来管理内容 The basic idea behind a Content Management System (CMS) is to separate the management of content from design. Cute Editor allows the site designer to easily create and establish templates to give the site a uniform look. Templates may be modified when desired. 在线图像编辑 People that input content on a website are generally not web designers, so most don't have that design & technical fibre in them. With online image editor, you can now edit image file with no image editing software to download or install! Easy drag and drop familiar interface. Resize, change dimensions, scale, crop, add text, optimize, rotate, flip, mirror and add watermark. 把图片存储于数据库 With CuteEditor you can easily use a Sql Server database or access database as the file storage. RTF到HTML的相互转换 With CuteEditor you can easily convert an HTML document into an RTF file and RTF file into HTML or XHTML document. 创建PDF文件 CuteEditor also allows you dynamically create Adobe PDF documents from ASP.NET. 高级文件上传模式 We integrate a hi-performance ASP.NET upload component - Ajax uploader into Cute Editor. Ajax Uploader allows you to select and upload multiple files at once. It also supports client side validation of the file size/type before uploading.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值