如何检查输入类型文本 [英] How to check input type text
本文介绍了如何检查输入类型文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<形式>
< input type =textname =mailplaceholder =输入您的用户名必填/>< br>
< button class =buttontype =submitonclick =window.location.href ='link.html'>继续< / button>
< / form>
你可以在这段代码中看到我正在使用输入类型按钮和按钮
我想要的是在重定向到link.html之前我希望输入文本是必需的
它重定向我没有检查类型文本
任何解决方案
i认为按钮不会这样做但我需要它重定向我link.html
我尝试了什么:
i尝试输入类型提交,但它没有将我重定向到链接我想知道为什么我将其更改为按钮类型按钮
解决方案
< 表格 action = link.html >
< 输入 type = text 名称 = < span class =code-keyword> mail 占位符 = 输入用户名 必需/ > < br / >
< 输入 < span class =code-attribute> type = submit class = 按钮 value = 继续 / >
< / form >
当前核心将显示验证,然后立即重定向。在这里我的建议,点击,调用一个函数。然后,在函数中检查文本框在重定向之前是否有值。
这是一个例子
CP_Redirect - JSFiddle [ ^
<form> <input type="text" name="mail" placeholder="Enter you username" required/><br> <button class="button" type="submit" onclick="window.location.href='link.html'">Continue</button> </form> as you can see in this code i'm using input type button and button what i want is before redirecting me to link.html i want the input text to be required its redirecting me without checking the type text any solution i think the button doesn't do this but i need it to redirecting me the link.html
What I have tried:
i tried input type submit but it doesn't redirecting me to the link that i want that why i change it to button type button
解决方案
<form action="link.html"> <input type="text" name="mail" placeholder="Enter you username" required/><br /> <input type="submit" class="button" value="Continue" /> </form>
The current core will display the validation then redirect immediately. Here my suggestion, On click, call a function. Then, in the function check if textbox has value before redirect.
Here is an example
CP_Redirect - JSFiddle[^]
这篇关于如何检查输入类型文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文