【问题标题】:javascript validation for a string given in the textbox of a form [closed]表单文本框中给出的字符串的javascript验证[关闭]
【发布时间】:2011-04-16 08:51:17
【问题描述】:

我创建了一个带有按钮的输入文本框的表单。

一旦我在表单的输入文本框中输入字符串“运行”(特别是),它应该显示包含三个框的页面。事情无法实现用于验证或检查特定“运行”字符串的 javascript .

但我得到的是包含页面的盒子。

请给我建议以帮助我解决这个问题。

【问题讨论】:

  • tagged java because , jsp, java-ee 都在那里,问题不是很清楚

标签: java javascript jsp


【解决方案1】:

我认为您想比较字符串“run”,如果匹配,则重定向到包含 3 个框的页面!

<html>
<head>
<script type="text/javascript">
function validatetxtbox()

{
    var txtfield;
    txtfield =document.getElementById('txtbox').value;

    if(txtfield == "run")
    {
alert("you entered string right");
window.onload="url u want to redirect after checking entered string is right"          
}
else
{
alert("Try again");
}
    }
    </script>
</head>

<body>
<input type="text" id="txtbox" maxlength="3">
<input type="button" id="btn" value="Send" onclick="validatetxtbox()">
</body>

【讨论】:

    猜你喜欢
    • 2014-06-14
    • 1970-01-01
    • 2011-05-27
    • 2013-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-10
    • 1970-01-01
    相关资源
    最近更新 更多