的document.getElementById(QUOT; ID&QUOT)。style.color [英] document.getElementById("id").style.color

查看:211
本文介绍了的document.getElementById(QUOT; ID&QUOT)。style.color的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写javascript验证器

并且我在输入不正确时更改输入字体颜色

但是我想要将此输入字体颜色更改回来输入是正确的

i不能做例如

i''m writing javascript validator
and i change input font color when the input is incorrect
but i want this input font color to be changed back when the input is correct
i cannot do eg

展开 | 选择 | Wrap | 行号

推荐答案

输入不正确时,
i更改输入字体颜色,但我想在输入正确时更改此输入字体颜色
i change input font color when the input is incorrect but i want this input font color to be changed back when the input is correct



如果if / else语句啊美女啊。我认为你的语言声明可能会妨碍你...你基本上是在说电子邮件是无效的,把它设置为红色,检查语言&给用户一条消息......然后将其设置为黑色。它在盲目的情况下做到了这一切。


此外,来自潜在用户填写表单的消息:如果我在我的电子邮件中犯了错误,我不想将其替换为错误消息,我想看到输入旁边的错误信息....无论如何,我已经用投掷者替换了它的那一部分。功能,您可以自己编写 - 并且可以包含语言声明


试试这个:

ah the beauty if the if/else statement. I think your polish language statement might be getting in the way..... you''re basically saying if the email is invalid, set it to red, check the language & give the user a message... then set it back to black. it does all this in the blind of an eye.

Also, a message from a potential user filling out your form: "if i made a mistake on my email, I don''t want to have it replaced with an error message, I want to see an error message next to the input".... anyway, i''ve replaced that part of it with a "thrower" function, which you can write yourself -- and can include the language statements

try this:

展开 | 选择 | Wrap | 行号


我尝试了这个为什么然后表单转到动作文件我的意思是返回false不起作用
i tried this why but then the form goes to the action file i mean that the return false doesnt work


展开 < span class =codeDivider> | 选择 | Wrap | 行号


这篇关于的document.getElementById(QUOT; ID&QUOT)。style.color的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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