Questions tagged [form-validation]

Denotes question related to form validation. form validation contain frontend forms, adminhtml forms, UI components based forms

Filter by
Sorted by
Tagged with
35
votes
7answers
65k views

Magento 2 - Form Validation

is there a overview for the new form validation attributes in Magento 2?
4
votes
3answers
7k views

Magento 2: How to set Max Length for Street Address?

I would like to set Max Length for Customer's Street Address 1 to 50 Characters & Street Address 2 to 100 Characters. Changes will be applied on Frontend only, where we can find Street Address. ...
1
vote
1answer
35 views

Magento2 restrict cc number in the form fields

I would like to restrict CC number (Ex: 4111111111111111) in the customer form fields in the magento2 frontend. Could you please advise me on how to do the step by step in Magento2. Expected Results: ...
12
votes
2answers
6k views

Validating form elements built via ui-components

I'm trying to have a custom validation to one of my Magento 2 form fields that is generated via ui-components. I know that I can make the value required by adding a validation item in the config. Like ...
23
votes
9answers
20k views

CE1.9.1 Please make sure your password match issue during User registration

I am encountering this issue in CE1.9.1. When a User registers (doesn't matter if it's during checkout or from the Create an Account link) the user keeps getting the password mismatch error even ...
10
votes
8answers
16k views

SUPEE-9767 Magento CE 1.9.3.3 Onestep Checkout not working with Form Key Validation On Checkout enabled [duplicate]

After upgrading to Magento CE 1.9.3.3, when I enable Form Key Validation on Checkout as recommended by SUPEE-9767 onestep checkout stops working. After selecting a payment method, when I click ...
2
votes
4answers
13k views

How to make last name optional in Magento 1.8

I've updated database directly to make is_required on lastname = 0. Removed the js validator for lastname in core. Removed required field in frontend in widget/name.phtml. However, The "Last name ...
10
votes
6answers
13k views

How to Validate the Google reCaptcha

I have added the google recaptcha in contact us form but value is also submitting without captcha. I have used in my contact page following codes for captcha: <div class="g-recaptcha" data-...
5
votes
2answers
10k views

Magento 2 form validation: minimum/maximum length

I'm trying to add some of the predefined validation to a form element but currently am failing. As fas as I can tell, all the validation rules can be added via classes, but no where does it say how to ...
4
votes
1answer
4k views

How Can I apply server side validation in magento 2

I am new to magento 2, and I want to apply server side validations, Can anyone please help me, Or suggest me how to apply. I have searched many links for this but i didnot understand. Here is my phtml ...
5
votes
1answer
2k views

Validation does not work in admin forms

I followed the advices of https://magento.stackexchange.com/a/8785/9489 and succeed to get that : $fieldsetImage->addField('logo_big', 'image', array( 'label' => Mage::...
3
votes
1answer
1k views

Magento 2: Custom validation for system.xml

Is it possible to create a custom validation for fields in configuration? (Stores > Settings > configuration) I created a system.xml file but the default values for the validate tag are not enough ...
2
votes
1answer
1k views

How to Validate Checkbox in Magento

In Form I have added code for checkbox as follows. $fieldset->addField('title', 'checkboxes', array( 'label' => Mage::helper('custommodule')->__('Title'), 'class' => '...
17
votes
3answers
9k views

Magento 2 add custom product attribute validation from install script

[ 'type' => 'int', 'backend' => '', 'frontend' => '', 'label' => 'XXXX', 'input' => 'text', 'frontend_class' => 'validate-greater-than-zero', 'source' => '', 'global' =>...
5
votes
1answer
8k views

UI form validation in Magento 2

I want to validate text field to numeric or not in UI form. <column name="sortorder"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> ...
8
votes
2answers
17k views

magento 2: trigger js form validation without submit

On a custom frontend page I have a form in which I use magento's js validation to validate inputs: name, email description, etc. When the form is submitted the validation is triggered and works ...
7
votes
2answers
14k views

Form Key Value in template and controller

The following function is used to get the form key in templates with type hidden. My customerController.php does not validate the form key with the method _validateFormKey(). When I echo the following ...
6
votes
3answers
14k views

Magento 2: phone number validation (only accepts numbers)

In Magento 2, I want to make phone fields number validation, (eg in the checkout page) only accepts numbers (and not characters)?
5
votes
1answer
6k views

How to make the second address field required during checkout?

I have config set to display 2 lines for address during checkout (Configuration → Customer → Customer Configuration → Name and Address Options): Number of lines in a street address: 2 How can I make ...
4
votes
1answer
7k views

Magento 2.2 Input field validation on Checkout page

In /vendor/magento/module-checkout/Block/Checkout/LayoutProcessor.php, I can find blow code (getBillingAddressComponent), which is used to validate the billing address input fields, and I can change ...
4
votes
1answer
1k views

Custom added field to checkout is not validating when I go the next step

I've added a date of birth field to the checkout in Magento 2 like so: <body> <referenceBlock name="checkout.root"> <arguments> <argument name="jsLayout" ...
2
votes
1answer
3k views

Magento 2: Image Upload JS Validation

I'm going to upload one image. I need to put below validations on Client side & Server Side Allowed file formats: jpeg, jpg, png Max. File Size is 5MB. Image size should be 100 Width x 100 ...
12
votes
2answers
7k views

magento2: how validation work in magento2

In magento1 we can check validation like this: var formToValidate = $('form-validate'); var validator = new Validation(formToValidate); if(validator.validate()) { // Here we can code ...
7
votes
4answers
1k views

Magento2 How to add custom validation for password?

I want to change default validation for all password field. I want to change for all password field and validation is minimum 8 characters and at least one number include. Can anyone help me with ...
3
votes
2answers
2k views

magento 2: how to make validation on same name array input

I want a validation on same name array dynamic input textbox.Because Magento data-validate="{required:true}" is not work on same name so how to validate same name array input validation.I have ...
2
votes
1answer
4k views

Admin form validation - making image file upload required [duplicate]

For backend part of my extension, I am trying to make one file required. The following code is not working. It is working fine for other text fields. $fieldset->addField('image1', 'image', ...
2
votes
2answers
1k views

Patching/rewrite files in lib/Varien

I would like to know people's thoughts on the best way to patch/rewrite Varien lib files. Specifically whey looking into a couple of issues one with checkboxes and one with image type inputs I found ...
1
vote
2answers
3k views

Magento 2 minimum length validation is not working for text field

Magento 2 minimum length validation is not working for text field. My code lines: <input type="text" tabindex="3" class="input-text required-entry validate-length maximum-length-8 minimum-...
3
votes
1answer
3k views

Adding custom global javascript validation

I have done some digging in internet but I haven't found any confirmed solution. What is the way to add custom js validation rule, that can be used globally as for example frontend_class for ...
2
votes
1answer
1k views

TypeError: t.validator.methods[a] is undefined issue in jquery validation in magento2

I am facing this issue TypeError: t.validator.methods[a] is undefined after adding jquery validation in my form. Here is my validation code: <script src="http://ajax.aspnetcdn.com/ajax/jquery....
2
votes
1answer
2k views

Magento 2 how to validate customer registration form on keyup event

I am working on a project where I need to validate customer registration form as customer types. I want to use the event keyup for inputs. I want to change the default messages also. Right now I am ...
1
vote
1answer
2k views

Using Javascript to validate response in the text box

I am new to Magento. I have the following requirements. A page has a text box where the customer enters an id. Once the id is entered, I need to check whether this id is available in the OMS using a ...
1
vote
1answer
2k views

DOB Validation with three fields in magento2

I need to change the "date of birth" field from date picker to three fields with validation. How to do it?
1
vote
1answer
10k views

How to write mobile number length validation in magento by prototype

I want to create mobile number validation in magento. Number should to be not less then 10 (7428832128).... i need to write this by prototype... basically i don't know how to write this....
1
vote
1answer
617 views

Custom Checkout Validation - Two fields must have the same value

I've created a module which adds an additional field to the checkout, called 'email-confirm'. I want to check that the value in this field is equal to the first email entry, but I'm unsure how to do ...
1
vote
0answers
568 views

Getting validation error on checkout billing tab for custom attribute

I have added two custom attribute named as country_code and mobile. And added those fields in app\design\frontend\base\default\template\persistent\customer\form\register.phtml And the fields ...
1
vote
1answer
2k views

Ajax form submit: Magento redirects to controller instead processing response

I'm working on a newsletter signup form (following this tutorial). When I hit the signup button Magento redirects me to the "form action url" and displays the response on a white page only: {"message"...
0
votes
1answer
88 views

How to change the type of validation used in fields on Magento 2 forms and where to find the list? [Q&A]

Say I wanted to validate my contact form to only accept UK phone numbers and a valid amount of currency, how would I do this in Magento 2? I want to change my contact form so it allows my users to put ...
0
votes
2answers
52 views

how to add magento2 checkout shipping form add validate-digits-range

I am trying to override checkout_index_index.xml using below code for minimum digits : <item name="telephone" xsi:type="array"> <item name="validation" xsi:type="array"> <...
0
votes
1answer
227 views

Magento textbox custom validation

I Need a custom form validation in a textbox The value should be like this 3-5, so <number>-<number> Please suggest me some ideas