#nikhil24 - field validation

1 messages · Page 1 of 1 (latest)

hollow hedge
#

Whats the context for this? Can you rephrase your questions or explain a bit more about what you're trying to do?

shrewd thorn
#

@hollow hedge When I enter value in CVC field and when i empty the values in CVC field, they have to validate saying that CVC field is empty

#

Could you please help me with that?

hollow hedge
#

Ah, gotcha

shrewd thorn
#

cardCvcElement.on('change', function(event) {
if (event.error) {
// show validation to customer
console.log("Field is empty");
}
});

When i write this code and add values in cvc and remove the values, even console.log value is not showing up 😦

hollow hedge
#

why are you checking only event.error?

#

there isn't necessarily an error

hollow hedge
#

Did you get this working?

shrewd thorn
#

Instead of event.error should I be using proper condition to check?

hollow hedge
#

Well when you log the entire event what do you see?

shrewd thorn
#

I m so sorry, how do we log entire event

hollow hedge
#

I mean just use console log for every event unconditionally, and log the whole event object

#

cardCvcElement.on('change', function(event) {
console.log({event});
});

#

eg

shrewd thorn
#

When i enter for postal code i am getting this

#

Currently postal code is not validating properly

hollow hedge
#

what part of that is not what you expect?

#

you were asking about empty CVC before, so this postal code question is new

#

What are you trying to do, exactly?

shrewd thorn
#

Its just a example i gave for cvc

#

Actually postal code is not validating correctly

#

that's the issue

#

error is want i want to see, as i have entered partial postal code

#

Currently i have added just 1 digit in postal code, it has to validate saying invalid postal code or something like that

hollow hedge
#

How are you managing that element? THat's not supported in split mode using your own postal code field as far as i know. You'd implement your own validation on the. value.

#

If you're using the combined card element with auto-validating postal code, for example, there are some errors that are useful about this.

shrewd thorn
#

Now i get it, actually is-invalid class is not getting added when i add 1 digit in postal code

#

How can i make sure is-invalid class is added during validation?

hollow hedge
#

How did you set up this element?

#

Try unfocusing the field, even in the single line form the validation error is not applied while focused/typing