Loading...

Във форума е въведено ограничение, което позволява на потребителите единствено да разглеждат публикуваните въпроси.

simon.kan1 avatar simon.kan1 9 Точки

07. Form Validation

Здравейте, успях да докарам задачата до 88/100 , само 1 тест гърми, и не мога да разбера от какво е, като даже инпут данните ми се струва че трябва да са вярни, но result div-a "valid"  го expect-ва да е 'none'

https://pastebin.com/em1y572x

https://judge.softuni.bg/Contests/Compete/Index/2767#6

https://judge.softuni.bg/Contests/Compete/Index/2767#0        -линк условия и ресурси

1.Form Validation

You are given the task to write validation for the fields of a simple form.

HTML and JavaScript Code

You are provided a skeleton containing the necessary files for your program.

The validations should be as follows:

  • The username needs to be between 3 and 20 symbols inclusively and only letters and numbers are allowed.
  • The password and confirm-password must be between 5 and 15 inclusively symbols and only word characters are allowed (letters, numbers and _).
  • The inputs of the password and confirm-password field must match.
  • The email field must contain the “@” symbol and at least one "."(dot) after it.

If the "Is company?" checkbox is checked, the CompanyInfo fieldset should become visible and the Company Number field must also be validated, if it isn’t checked the Company fieldset should have the style "display: none;" and the value of the Company Number field shouldn’t matter.

  • The Company Number field must be a number between 1000 and 9999.

Every field with an incorrect value when the [Submit] button is pressed should have the following style applied border-color: red;, alternatively if it’s correct it should have style border: none;. If there are required fields with an incorrect value when the [Submit] button is pressed, the div with id="valid" should become hidden ("display: none;"), alternatively if all fields are correct the div should become visible.

Constraints

  • You are NOT allowed to change the HTML or CSS files provided.

Screenshots

Hints

  • Use addEventListener() function to attach an event listener for the "change" event to the checkbox.
  • All buttons within a <form> automatically work as submit buttons, unless their type is manually assigned to something else, in order to avoid reloading the page upon clicking the [Submit] button you can use event.preventDefault()
  • The validation for the separate fields can be done using regex.
Тагове:
0
JavaScript Advanced
BGdaredevil avatar BGdaredevil 8 Точки

За съжаление пейстбина е изтекъл -- качвам моето решение -- https://pastebin.com/URN1i1br

0
PavletaT avatar PavletaT 11 Точки

Благодаря, бях забила на 66/100 и кодът ти много ми помогна :)

0
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.