the input value is invalid что делать

Can I mark a field invalid from javascript?

From reading this post I have found that there are some pseudo classes for ‘valid’ and ‘invalid’ input values introduced to HTML5.

Is there a way I can mark an input field as invalid/valid from javascript? Or alternatively, can I override the validation method used?

the input value is invalid что делать. Смотреть фото the input value is invalid что делать. Смотреть картинку the input value is invalid что делать. Картинка про the input value is invalid что делать. Фото the input value is invalid что делать

3 Answers 3

You could use the customValidity function for this purpose.

If you add a customValidity message to the field, it becomes invalid. When you set the message as an empty string, it becomes valid again (unless it is invalid because of other reasons).

field.setCustomValidity(«Invalid field.»); will make the field invalid.

field.setCustomValidity(«»); will make the field valid unless it fails an HTML5 constraint.

Edit: Someone clarified that you’re looking for «valid» «invalid» attributes for DOM.

You could run this function each time an element loses focus, or whenever you want.

Not exactly elegant, but unfortunately there’s no «pseudo» support with javascript and HTML5 now.

If I understand your question, you can do validation with Javascript. However, be warned that it is very easy to circumvent client side validation, especially javascript validation. You should never trust client data and always do checking on the server side.

For example, I could easily find element IDs by inspecting the source code, then do document.getElementById(‘some_id’).setAttribute(‘max’, new_number) to change the max value (this was one of the entries from your link).

There are various ways to do it, so I’ll try to give you the general idiom.

Then you have the value in a variable, there are various ways to check it.

Now for the validation part: add onsubmit=»return validateForm() to your form tag where validateForm() is the function which does all the checking. And the function just returns true if valid and false otherwise. This overrides the default validation function (which by default does nothing).

Of course, if you don’t want to check all the fields you only have to return true if the certain ones pass. Again, you shouldn’t rely on this, but if you’re only out to deter average people then it’s an easy solution.

Источник

Invalid Input Errors

Guide to troubleshooting invalid input errors

DIRECT_INTEGRATION_NOT_ENABLED

An attempt was made to create an Item without using Link.
Common causes
Troubleshooting steps

In the Development or Production environments, use Link to create the Item. In Sandbox, use /sandbox/public_token/create

INCORRECT_DEPOSIT_AMOUNTS

The user submitted incorrect Manual Same-Day micro-deposit amounts during Item verification in Link.
Common causes
Troubleshooting steps

Have your user attempt to enter the micro-deposit amounts again.

INVALID_ACCESS_TOKEN

Common causes
Troubleshooting steps

Make sure you are not using a token created in one environment in a different environment (for example, using a Sandbox token in the Development environment).

If you have their permission to do so, ask the user whether they have revoked access via my.plaid.com. If your user has indeed revoked permission, they will need to re-enter the Link flow to connect their Item again.

INVALID_ACCOUNT_ID

The supplied account_id is not valid
Common causes

One of the account_id (s) specified in the API call’s account_ids object is invalid or does not exist.

Troubleshooting steps

Verify that your integration is passing in correctly formatted and valid account_id (s)

Also be sure to preserve the case of any non-numeric characters in Plaid identifiers, as they are case sensitive.

Verify the Item’s currently active accounts and their account_id (s).

If the Item is at an institution that uses OAuth-based connections, the user may have revoked access to the account. If this is the case, It is a security best practice to give the user a choice between restoring their account and having your app delete all data for that account. If your user wants to restore access to the account, you can put them through update mode, which will give them the option to grant access to the account again.

Either repeat the call you made that received this error without the optional account_ids object, or make a call to /item/get to return all of the current account_id (s) for the Item. You may then present this updated list of accounts to the user so that they may select which of their accounts they would like to use with your integration.

Verify that the account_id was not erroneously removed from the API.

Источник

Change the colour of a label when an input is invalid

I am making a template driven form in angular and I want to be able to change the colour of the label of an input e.g. a select, when the select is invalid.

Here is an example of of a select input from the form:

When a select is invalid, the class ng-invalid is added to the element.

It is easy enough to change the select styling with:

I also want to change the label colour when the select is invalid. I found the following on stackoverflow:

This uses sibling combinators but then I have to reorder my elements and hack them around with positions. I was wondering if there is a better was to do it with SCSS and/or angular?

4 Answers 4

just saw your comment about looking to do this with css. if that’s the case then you probably want to use the :has() selectors.

here is the documentation

I would suggest using reactive forms instead of the two way binding you are currently using. this will allow you to add any class you want based on the validity of a form or FormControl.

Here is the official guide to reactive forms from Angular

at a high level, doing suching such as the following in your class.

then in your template you can do something along the lines of

by using reactive forms, you can see that you can add classes to your labels based on if the form is valid [class.invalid]=»form.invalid»

reactive forms are fairly useful, especially if your forms will grow beyond just a single form field

Источник

The value «» is invalid

Why does the Edit screen show the value I’m editing but when I try to save, the Edit HTTPPOST has a null object?

Getting a an error I’ve tracked down but don’t see the cause of. I have a class used for a drop list, so it only has AdvisoryTypeID and AdvisoryType. But now I’m creating screens for users to see all in a grid (Index), add new (Create), and change existing ones (Edit). The index screen reads from the DB no problem. So does Edit. Create doesn’t need to.

But both Edit and Create give the same error on HTTPPOST. The error is «The Value ‘whatever I typed in’ is invalid». Debugging the code turned up why: the «advisoryTypes» variable is null for reasons I don’t understand:

CONTROLLER (for Edit post)

I have compared this to another screen that does Edit and Create fine and they’re identical (except field names, for example). I’m stumped.

CONTROLLER (for Edit Get)

PART TWO Now some odd background: this is the first model/controller/view I created since updating EF from 5 to 6 alpha3 (had to because I had POCO and edmx in same project and this solved that bug). I created the model manually. When I tried to create the Controller via the wizard, the wizard gave an error «Unable to retrieve metadata for ProjectName.Models.AdvisoryProviders’. Unable to cast obect of type ‘System.Data.Entity.Core.Objects.ObjectContext’ to type ‘System.Data.Objects.ObjectContext’.».

The result was having to manually create the controller by copying/pasting another one and making changes, then creating my views the same way. I’m suspicious this is all related but maybe not. If this proves unrelated I’ll remove this and post as another question.

Источник

date field validation bug #764

Comments

michal-demecki-profil-software commented Jan 30, 2020

Describe the bug
When yup.date() field gets empty string for validation, it throws error even if field is nullable or not required.

ValidationError: required must be a date type, got: «Invalid Date» instead

Platform (please complete the following information):

The text was updated successfully, but these errors were encountered:

melogustavo commented Feb 19, 2020

Hey, I was taking a look at your code and I think that this is not a bug.
When you define it as a date() it can’t receive a string, even if it is empty. So it will always return invalid if you try to pass an empty string. If you don’t pass any data and it is defined with the nullable it will work as intended. Maybe, in this case, you should send not send the data information or send it as null.

I don’t know if this was of any help, hope that it helped you.

ghost commented Apr 11, 2020 •

Looks like this has occurred before: #434

4ortytwo commented Jun 29, 2020

I saw your message on RHF Spectrum, had to struggle with this as well. I’ve come up with this solution:

I check the selected value onChange and if it’s an empty string, I set it to undefined.

Yup is happy and I have a nice error message instead of
delivered must be a `date` type, but the final value was: `Invalid Date` (cast from the value `»»`).

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *