如何使一个字段需要输入一个特定的数字? [英] How to make a field required to enter a specific number?

查看:107
本文介绍了如何使一个字段需要输入一个特定的数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何输入特定的数字或文字所需的字段[如:激活码]
和在确认回答的情况下移动到网页的按钮

I want to know how can I make a field required to enter a specific number or text [like: Activation code] and a button to move to a 'Web page' in the case of confirmatory answer of the input and move to 'another page' in the case of non-confirmatory.

推荐答案

这里是 < a href =http://jsfiddle.net/mdesdev/XjTL9/ =nofollow> FIDDLE

<input type="text" class="input" placeholder="Enter activation code">
<input type="button" class="button" value="Confirm">







$(function() {
  var code = '2528-3265-7592';
  $('.button').click(function() {
    if($('.input').val() === code) {
       window.location = 'http://google.com';
    }
    else {
       window.location = 'http://yahoo.com';
    }
  });
});

这篇关于如何使一个字段需要输入一个特定的数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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