HTML编码 - 密码设置 [英] HTML Coding - Password setting

查看:108
本文介绍了HTML编码 - 密码设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


请您帮我解决以下问题。


我已尝试过以下HTML编码,需要 帮助。


如果密码与"Nature!555"匹配。那么超链接应该打开。例如,超链接可以是'WWW.GOOGLE.COM'


如果密码不匹配,那么它应该出现'错误的密码'


<请你帮我解决这个问题。


< head>

< script type =" text / javascript">

函数isValid(){

var password = document.getElementById('password')。value;

if(password ==" Nature!555" )

{alert('Correct!')}
$
其他

{alert('密码错误')}¥b $ b}

< / script>

< / head>


< form name =" PasswordField" action ="">

密码:

< input type =" password" ID = QUOT;密码" name =" password">

< input type =" button" value ="登录" onclick =" isValid();">

< / form>



谢谢,


Ashok


解决方案

我只是添加了窗口正确警告后的.location.href。

 function isValid(){
var password = document.getElementById('password')。value;
if(password ==" 000"){
alert('Correct!')
window.location.href ='http://www.google.com';
}
else {
alert('密码错误')}
}

 这是一个代码,看看我做了什么并从中学习:
http: //codepen.io/lyellick0506/pen/cItvw


我更改了密码以便于测试。


-Link














Hi,

Please could you help me on the below scenario.

I have tried the below HTML coding and need assistance.

If the password matches "Nature!555" then the hyperlink should opens. for Example the hyperlink could be 'WWW.GOOGLE.COM'

if the password does not match then it should come up with 'Wrong Password'

please could you help me on this.

<head>
<script type="text/javascript">
function isValid(){
var password = document.getElementById('password').value;
if (password == "Nature!555")
{alert('Correct!')}
else
{alert('Wrong Password')}
}
</script>
</head>

<form name="PasswordField" action="">
Password:
<input type="password" id="password" name="password">
<input type="button" value="Log in" onclick="isValid();">
</form>

Thanks,

Ashok

解决方案

I simply added window.location.href after your correct alert.

function isValid(){
   var password = document.getElementById('password').value;
   if (password == "000"){
     alert('Correct!')
     window.location.href='http://www.google.com';
   }
 else {
   alert('Wrong Password')}
 }

 Here is a codepen to see what I did and learn from it: http://codepen.io/lyellick0506/pen/cItvw

I changed the password to make testing easier.

-Link








这篇关于HTML编码 - 密码设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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