【发布时间】:2015-09-14 21:12:06
【问题描述】:
我的场景如下: 我将从文本框中获取字符串输入,一旦用户单击提交按钮,这将分割一些字符。到目前为止,这是我的工作:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication2.WebForm2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script>
function Check()
{
var inputBox = document.getElementById("TextBox1").value;
if (inputBox == "") {
alert("Enter your full name.");
}
var str = inputBox.value;
var result = str.slice(1, 4);
alert(result);
}
</script>
</head>
<body>
<form id="form2" runat="server">
<div>
<table>
<tr>
<td>Enter your full name: </td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td></td>
<td><button type="button" onclick="Check()" >Submit</button></td>
</tr>
</table>
</div>
</form>
</body>
</html>
【问题讨论】:
-
我自己找到了答案,我需要做的就是删除 .value。如果有人给我一点提示如何在jquery中编写上面的js,那将是非常棒的。
-
你想对输入的文本做什么?你能详细解释一下吗?
-
你想要实现什么(详细),你当前的代码做了什么不是你想要的?您能否编辑您的问题以添加更多信息?谢谢!
-
我正在学习 js,所以我想创建一些东西,因为输入文本将切片到 (1,4)
标签: javascript html slice