Javascript验证表格帮助。 [英] Javascript validation form help.

查看:61
本文介绍了Javascript验证表格帮助。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我对Javascript很新,我只对简单的Javascript有所了解。


我必须开发一个Javascript验证表单对于一个项目。我已经这样做了,使用最简单的方法。提交表单后,会显示相应的错误,但是,重新提交时,错误不会更新(它们仍然存在)。我有一些关于解决这个问题的想法,但我对Javascript这么新,以至于我的命令知识受到严重限制。我见过其他功能形式,但大多数比我的复杂得多。我可以使用一个简单的规则来修复我的Javascript表单吗?我猜我需要另外一个功能。



现在,网页(甚至是表格​​)非常大,所以我会显示脚本:

Hello,
I am very new to Javascript and I''ve only understanding for simple Javascript.

I had to develop a Javascript validation form for a project. I have done so, using the most simple methods. After submitting the form, the appropriate errors show, but, when resubmitted, the errors are not updated (they are still present). I''ve had a few ideas about fixing this, but I''m so new to Javascript that my knowledge of commands are restricted heavily. I have seen other functioning forms but most are a lot more complex than mine. Is there a simple rule I can incorporate to fix my Javascript form? I''m guessing I''ll need another function.


Now, the web page (and even the form) is quite large, so I''ll just show the script:

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

推荐答案

哦,我知道我应该为目录创建变量..
Oh and I know that I should have made variables for the directories..


有更好的方法可以做到这一点,但让我们先处理你的代码。


你需要添加 else 将错误消息设置为"当没有错误时,例如
There are better ways to do this, but let''s just work with your code first.

You need to add else to set the error message to "" when there''s no error, e.g.
展开 | 选择 | Wrap | 行号


@acoder


谢谢,这比预期容易得多。我会重新编写代码,然后选择最佳答案。

再次感谢。
@acoder
Thankyou, that was much easier than expected. I''ll just re-write the code and then chose your answer as best.
Thanks again.


这篇关于Javascript验证表格帮助。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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