HOW TO force showing invalid data in the form fields?

Discuss everything related to DataValidator. All versions. Any questions related to the DataValidator developing or using should be posted to this forum.

Moderators: alexandrleonenko, goas

administrator
Site Admin
Site Admin
Posts: 6020
Joined: Jan 7th, '09, 23:18
Contact:

HOW TO force showing invalid data in the form fields?

Postby administrator » Oct 18th, '13, 07:51

The DataValidator only responsible for validation of data, so this operation must be done manually by yourself.

Example:

Code: Select all

<input type="text" value="<?php echo (isset($_POST['age'])) ? htmlentities($_POST['age']) : '' ?>" name="age">

vorn10
Newbie
Newbie
Posts: 1
Joined: Feb 27th, '19, 18:55

Re: HOW TO force showing invalid data in the form fields?

Postby vorn10 » Feb 27th, '19, 18:58

I need to be able to validate certain fields even if they were never touched by the user. Some fields are required, however, at least as I've experienced it so far, a required field is not invalidated on submit: it is only invalidated on blur. So if the user never actually touches a field (or any fields, for that matter), and hits submit, the form will validate successfully and submit, causing server-side validation errors.

My question regarding AngularJS form validation: How do you FORCE the entire form to validate on submission, regardless of whether a user has actually touched any form fields or not?

I have a bunch of forms, and on most forms there are several required fields, as well as fields with min/max and maxlength requirements. If I just build an AngularJS form, apply directives like ng-required, and hit submit, the forms always submit. Nothing stops it.

I need my forms to NOT submit if required fields are empty, regardless of whether the user has actually touched them and left (which is the only way a blur event will fire, and therefor the only way those fields will be validated.)

Using the "disabled" submit button approach is unacceptable for me here.

MongoDB Tutorial


Return to “ApPHP DataValidator”