omarshammas / jquery.formance

A jQuery library for formatting and validating form fields, based on Stripe's jQuery.payment library.
omarshammas.github.io/formancejs
Other
632 stars 105 forks source link

Field type text required #21

Open viniciusjau opened 9 years ago

viniciusjau commented 9 years ago

Hi guys!

How create a field type text required? To use in a field with the name...

jh3y commented 9 years ago

Hey @viniciusjau,

Could you elaborate?

Forgive me, for I haven't looked at the project for some time. But, if you have a field that is of type text and required, you could simply use the HTML5 attribute required attribute if using a browser > IE9 and !Safari. It also depends on the context and set up of your project. For example, something like Angular has this functionality available within its basic validation directives. Or jQuery validate also offers a solution to requiring input in a field.

Formance caters to more specific fields with regards to their validation and formatting.

@jh3y

viniciusjau commented 9 years ago

Yes could use the HTML5 attribute.. but I would not get this effect form

jh3y commented 9 years ago

The effect is achieved using CSS. You could write some CSS and apply it to your input. For the invalid label either opt to use maybe a CSS pseudo element or a styled label that appears in a show/hide manner.

@jh3y

autoboxer commented 8 years ago

I agree, having a base required field type would be very helpful. The benefit of a library like this is consistency through the validation handling. Most users will have a need for this basic functionality and won't want to roll their own solution using the HTML5 attribute.