密码正确吗?然后重定向 [英] Password correct? then redirect

查看:92
本文介绍了密码正确吗?然后重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:
密码HTML重定向


所以我有这个代码,我只需要它当正确的密码被添加时重定向。唯一的问题是,我不知道要添加什么,如果密码是hello,它只会重定向。
我明白使用view-source会显示密码,我不介意,它的我想要的方式。
我基本上只需要知道要添加什么以及在哪里添加它。



Sooo:
如果将hello输入到密码字段中,则重定向。
如果还有其他东西放在密码字段中,则不做任何事。

 < div class =wrapper> 

< form class =form1action =http://google.com>

< div class =formtitle>输入密码继续< / div>

< div class =input nobottomborder>
< div class =inputtext>密码:< / div>
< div class =inputcontent>

< input type =password/>
< br />

< / div>
< / div>

< div class =buttons>

< input class =orangebuttontype =submitvalue =Login/>


< / div>

< / div>

我希望这一点很清楚,可以理解。



更新:



输入密码以继续

 < div class =input nobottomborder> 
< div class =inputtext>
密码:
< / div>

< div class =inputcontent>
< input type =passwordid =password/>< br />
< / div>
< / div>

< div class =buttons>
< input class =orangebuttontype =submitvalue =Continueonclick =if(document.getElementById('password')。value =='hello')location.href ='members。 html'; else alert('错误密码!'); />
< / div>
< / form>

解决方案你必须使用JavaScript。您所需要的只是登录按钮上的事件侦听器,然后您检查输入字段的值并重定向。这很简单,可以用普通的javascript来完成,但使用jQuery更容易。
它应该是这样的(但我没有测试代码)。

  $('。orangebutton ').click(function(){
if($('input:password')。val()==hello){
window.location.href =http:// stackoverflow .com;
}
});

当然,您必须包含jquery库并确保dom已加载。


Possible Duplicate:
Password HTML redirect

So I have this code and I need it to only redirect when the correct password is added. Only problem is that I dont know what to add that will make it only redirect if the password is "hello" I understand that using "view-source" would reveal the password, I don't mind that, its the way I want it. I basically just need to know what to add and where to add it.

Sooo: Redirects if "hello" is typed into password field. Does nothing if anything else is put into the password field.

<div class="wrapper">

    <form class="form1" action="http://google.com">

        <div class="formtitle">Enter the password to proceed</div>

        <div class="input nobottomborder">
            <div class="inputtext">Password: </div>
            <div class="inputcontent">

                <input type="password" />
                <br/>

            </div>
        </div>

        <div class="buttons">

            <input class="orangebutton" type="submit" value="Login" />


        </div>

</div>  

I hope this was clear and could be understood.

UPDATED: Enter the password to proceed

    <div class="input nobottomborder">
        <div class="inputtext">
            Password:
        </div>

        <div class="inputcontent">
            <input type="password" id="password" /><br />
        </div>
    </div>

    <div class="buttons">
        <input class="orangebutton" type="submit" value="Continue" onclick="if (document.getElementById('password').value == 'hello') location.href='members.html'; else alert('Wrong Password!');" />
    </div>
</form>

解决方案

You will have to use javascript. All you need is an event listener on the login button, then you check the value of the input field and redirect. This is simple enough to do it with plain javascript, but it's even easier with jQuery. It should be something like this (but I haven't test the code).

$('.orangebutton').click(function () {
    if ($('input:password').val() == "hello") {
        window.location.href = "http://stackoverflow.com";
    }
});

Of course you have to include jquery library and make sure that the dom is loaded.

这篇关于密码正确吗?然后重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆