Skip to content
Advertisement

Email validation using Javascript doesn’t work with HTML

I’m trying to let user check if his email adress pass RFC standard, comparing it with regular expression dropped below.

I already checked few examples on console using function responsible for excecute validation test. I’m aware of possibilities that my regex is not ready for, but whenever I tried a few examples on console – it works.

Problem begins when function gets value from included ‘text’ HTML form.

Using Javascript I also checked how value is interpretated by browser (Simply pasting text into another div) – result is ok.

Why validation doesn’t work properly whenever use input value on HTML forms?

JavaScript
JavaScript

Advertisement

Answer

While this may not be the best of code example, the simple solution to your issue lies in document.form1.text. Simple change it to document.forms.form1.text.

E.g.

JavaScript

EDIT:

I missed the .value before. Now it should work.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement