I have multiple select and 2 text fields for advance multiple search in Magento eshop. The text field 1 has the value "Price Low" and the 2nd "Price High".
I want to disable the submit button until the user fills in only with numbers in the text fields, whose IDs are: "searchbar" and "searchbar2".
My problem is that if nothing is filled in the text field and the user submits the data, it will query "Price Low" & "Price High" text fields in the result and it will mess with the other values ("brand" etc).
Magento forms already use Really Easy Field Validation for Javascript so all you need to do is give those fields a class="required validate-number" and the rest is automatic.
However on the server side you should must validate all fields yourself if not for better searching then for security reasons. Remember the programmer's mantra; Garbage In, Garbage Out!
Related
I have a JSON which I have extracted. There is a field under the node 'NumberBlockDetails' under that, there is a field 'AreaCode' which is displayed as iterated. Currently based on the iteration, that field 'AreaCode' is displaying four times. It is based on one lightning-input condition only. But now as the user edits any one, the combobox is displayed under all 4 fields of Areacode. How can I display it only on 'Areafield' which has a user Action (like Onchange).
````<ul key={num}>
````<lightning-input type="text" label="AreaCode" value={userValue}> </lightning-input>
````<template if:true={flagValue}
````<lightning-combobox
````name=""
````options={}
````</lightning-combobox>
````</template>
````</ul>
````</template>
Currently for all 4 it is displaying when user clicks inside the field, how to show only under the field which is currently in action by the user for the same <lightning-input> field.
Can anyone suggest on this
Scenario/Context
I've got a drop down menu with two input elements underneath.
From the dropdown menu, are names of companies (with values set to the respective company id's), and another prompt to Add a new company.
If the option to Add a new company is selected from the dropdown, then the user is to fill out the 2 input field elements (i.e. company name and company email).
Otherwise, if an available company is selected from the dropdown,
then the 2 input fields (for company name and email are to be disabled).
My question
Is this possible to do without an AJAX call if I want things to happen without a page refresh?
Can anyone suggest some other alternatives??
Many thanks!
That is absolutely possible, though you'd need to use some JavaScript to make it happen and load a bit more data to the DOM on the initial page load.
For each option in your company select dropdown, add a data attribute for the name and email.
Then, watch that dropdown for the change event in JavaScript. Whenever that event is fired, if the data-company-name and data-company-email attributes are defined for the selected option, disable the input fields and populate them with those values. If those data attributes are not defined for the option (likely only for your 'Add a new company' option), then clear the values from the input fields and enable them.
I'm facing one weird problem on the Contact entity. I do have one check box type field on the Contact form. When user selects (ticks) this checkbox at that time I'm making one field as mandatory in the BPF. This is a two options (yes/no) field on the BPF.
The problem is when on click of the checkbox on the form, the BPF field displays "click to enter" text, not sure why it is showing this text on the field.
On "Price List Item" entity, we have an "amount" field of type currency. We require limiting the user to enter the amount in that field up to 2 decimal places only. Example, if the user wishes to enter 100.100 then he should not be able to write only up to 2 decimal places ie. 100.10Image shows the invalid value allowed to enter
It's not possible without doing something unsupported. You can attach to the key press event of a text field, but not any other type of field.
If you wish to follow a dark and dangerous path, aka the unsupported route (and note that I do not advise this), you can still attach to the underlying inputs. Using something like this in jquery for example:
function onload()
{
$("#amount_i").keypress(...);
}
But that's a rabbit hole I shall not venture down any further. In regard to CRM I'm very much a blue pill kind of guy.
You can hide the field and insert a HTML webresource mimicking the field. In a HTML web resource you are free to manipulate the DOM (i.e. limiting input) without risking breaking anything in the form itself.
If you include the ClientContext.js.aspx in the web resource, you can then copy what's entered in the "fake" field to the "real" field (via parent.Xrm, remember to uncheck 'Prevent cross-frame scripting').
This has the benefit of not requiring tampering with the form's DOM, and an HTML page with a single input field shouldn't be that hard to implement.
What would be the best design layout for a web form with more than 100 fields? Right now I have grouped the fields to tabs.I am having tough time in validating the fields.I should either validate it on 'Submit' of the form or on tab change.Both has its own drawbacks. If I validate on tab change then user cannot view other tabs till they fill all the mandatory fields in the previous tab.Also it is not an good idea to throw so many validation messages to the user when he submits the form.
Please share your thoughts..
You can use a stepwise process. In the first step provide all the most important fields. Then on the click of a 'Next' button you can go to the next step and so on. By validating the fields you can allow the user to go to the next step.