拒绝错误 [英] reject error

查看:88
本文介绍了拒绝错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用javascript拒绝value = viagra的表单输入,

但它根本不起作用。


第30行最后一次尝试让代码工作的地方是。
http://html-channel.com/pastebin.php?id=2

任何人都可以帮我这个吗?


-

Torbj?Petteren

解决方案



Torbj ?Pettersen写道:

一个表单输入,其中value = viagra将被使用javascript拒绝,
但它根本不起作用。

第30行和第30行是最后一次尝试使代码工作的地方。
http://html-channel.com/pastebin.php?id=2

任何能够帮助我的人?
document.MyForm.Name.value.toLowerCase()。equals(''viagra'')




你有什么理由不能只需执行以下操作:


document.forms [" MyForm"]。elements [" Name"]。toLowerCase()==" viagra"


因为没有String方法等于。


web.dev写道:

< blockquote class =post_quotes> document.MyForm.Name.value.toLowerCase()。equals(''v iagra'')



你有什么理由不能只需执行以下操作:

document.forms [" MyForm"]。elements [" Name"]。toLowerCase()==" viagra"

因为那里是没有String方法等于。




没用。 :-(


-

Torbj?Pettersen




Torbj?姓Pettersen写道:

web.dev写道:

document.MyForm.Name.value.toLowerCase()。equals (''v iagra'')



是否有理由不能简单地执行以下操作:

document.forms [" MyForm" ;]。元素[" Name"]。toLowerCase()==" viagra"

因为没有String方法" equals"。



>不工作。: - (




JavaScript String对象中没有方法equals。使用简单的

比较而是建议:


//错误:

if(document.MyForm.Name.value.toLowerCase()。equals(''viagra'') )


//右:

if(document.MyForm.Name.value.toLowerCase()==''viagra'')


A form input where value = viagra is to be rejected using a javascript,
but it doesn''t work at all.

Line 30 and on is where the last attempt to get the code to work is.
http://html-channel.com/pastebin.php?id=2

Anyone able to help me with this?

--
Torbj?rn Pettersen

解决方案


Torbj?rn Pettersen wrote:

A form input where value = viagra is to be rejected using a javascript,
but it doesn''t work at all.

Line 30 and on is where the last attempt to get the code to work is.
http://html-channel.com/pastebin.php?id=2

Anyone able to help me with this? document.MyForm.Name.value.toLowerCase().equals('' viagra'')



Is there a reason why you can''t simply do the following:

document.forms["MyForm"].elements["Name"].toLowerCase() == "viagra"

Because there is no String method "equals".


web.dev wrote:

document.MyForm.Name.value.toLowerCase().equals(''v iagra'')



Is there a reason why you can''t simply do the following:

document.forms["MyForm"].elements["Name"].toLowerCase() == "viagra"

Because there is no String method "equals".



Didn''t work. :-(

--
Torbj?rn Pettersen



Torbj?rn Pettersen wrote:

web.dev wrote:

document.MyForm.Name.value.toLowerCase().equals(''v iagra'')



Is there a reason why you can''t simply do the following:

document.forms["MyForm"].elements["Name"].toLowerCase() == "viagra"

Because there is no String method "equals".



Didn''t work. :-(



There is not method "equals" in JavaScript String object. Use simple
comparison instead as suggested:

// WRONG:
if (document.MyForm.Name.value.toLowerCase().equals('' viagra''))

// RIGHT:
if (document.MyForm.Name.value.toLowerCase() == ''viagra'')


这篇关于拒绝错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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