jQuery Validate formatting rules for range limits - asp.net

I have a large table of text inputs for which a set of custom attributes are being created on the server side. These attributes included "min" and "max" which were used with the jQuery Validate plugin.
Due to a change in the requirements (of course), we now have to update the attributes to a range type, however the Validate plugin isn't interpreting the formatting of the range rule correctly (or perhaps it's more accurate to say I'm not formatting the rule correctly) and now I have problems.
The generated output for the input boxes looks like this:
<input type="text" producttype="CCC" code="ESTFEE" range="460, 500" class="currency required" id="txtEstFeeCCC" value="460.00" name="txtEstFeeCCC">
I've also tried the following:
<input type="text" producttype="CCC" code="ESTFEE" range="[460, 500]" class="currency required" id="txtEstFeeCCC" value="460.00" name="txtEstFeeCCC">
In either case, the message returned is either:
Please enter a value between 4 and 6.
or
Please enter a value between NaN and 4
respectively. Neither of which has anything to do with the 460 - 500 range in question.
The jQuery code calling the validate function is just the vanilla call:
$("#btnSave").click(function() {
validator.form();
...
});
How should an input attribute for jQuery Validate range be formatted so that the correct number range limit is displayed?

You should be able to do:
<input type="text" id="field1" name="field1" class="{required: true, range: [460, 500]}">
You could, of course, always just store the values as a range but output as min and max properties still

Related

When validate Q-Select with vee-validate 4, the use-input attributes is not working and don know why the value appearing twice

Here is my code
<Field
name="options"
rules="required"
v-slot="{ errorMessage, value, field }"
>
<q-select
filled
dense
use-chips
use-input
multiple
:model-value="value"
:options="state.options"
label="Filled"
v-bind="field"
:error-message="errorMessage"
:error="!!errorMessage"
/>
</Field>
How do I use the use-input attributes and remove the double value that display in the select field? Please help thank you.
Q-Select-validation
Issue solved Thanks to logaretm.
Because v-bind="field" is doing a bunch of even listening which conflicts with that component. The field object doesn't know the kind of the component/element so it tries to cover as much cases as possible by listing to input, change, update:model-value events. In that component case it is possible it emits both input and update:model-value because of the text input inside it.
You can fix it by being selective of what events should change the value with handleChange.
https://stackblitz.com/edit/vee-validate-v4-quasar-framework-gbma2c?file=src%2FApp.vue

XQuery: Access value in node

I have text-input-boxes on a website which I´m accessing via XQuery. Something like this on the website:
<input id="input1" type="text" value="300">
I need to access the "value" fields, but I´m missing the idea here how to do this.
Here´s the code I´ve tried:
let $doc := html:parse(fetch:binary('websiteaddress'))
return
<datarow>
<input1>{data($doc/html/body/div/div/div/div/div)}
</input1>
</datarow>
As result I get all the description text on the website, but not the fields itself.
At the end I would need datarows with the "value". So I guess I have to do something like $doc//div[#id="input1"]?....but how to access the value?
Any ideas on that?
You can access the attribute values with the attribute axis.
Most people use the abbreviated syntax #:
$doc//input[#id="input1"]/#value
but you can also use attribute:::
$doc//input[#id="input1"]/attribute::value

How can I translate input use ngx-translate?

<input type="text" name="title" [(ngModel)]="dataAdd.titleEN">
<input type="text" name="title" [(ngModel)]="dataAdd.titleFR">
I need to show two title but different language
If I click of button en show text in English or fr show text in French
and save in variable string
Note: I need unique variable for unique data insert in Firestore
dataAdd = {
titleEN: '',
titleFR: '',
}
this.translateList = this.afs.collection('translates');
this.translateList.doc('en').set({
TITLE_FOR_RENT: this.dataAdd.titleEN,
});
this.translateList = this.afs.collection('translates');
this.translateList.doc('fr').set({
TITLE_FOR_RENT: this.dataAdd.titleFR,
});
In my opinion you have assumed wrongly the usage of ngx-translate, this package is used in order to support multiple pre defined languages , for example if you want to support en and fr , beforehand you must have a .json file for each desired language, with the following KvP structure => where the key is a universal key (some string that is the same in each json file), which is used to map values to the translations from the .json files. You can check out the official StackBlitz Demo for detailed example of the usage.
In order to achieve the result that you described, I would suggest to use something like Cloud Translation API provided by Google, which is able to translate live user inputs (or whatever you pass to the API), after that depending on your strategy you might display the response from the API directly to the client, or load it first in the ngx-translate and then display it to the client.
Note:
I would go for the first option, because I assume in your case filling the browser memory is unnecessary (because when loading the translation trough in ngx-translate you are just feeling one big js object behind the scenes)

jsViews and linkTo syntax

I'm using jsViews to build a small app.
I have a input form section in which I want to provide a cancel button and a save button.
My goal is very similar to the linkTo section of the documentation.
However, my data-link is a bit more complex. I didn't find the correct syntax to bind data back to my editing object.
Here's what I have:
<input type="text"
data-link="{:Data.ListName:Editing.ListName}
id{:'txtListName_' + #getIndex()}" >
The textbox is populated with my backend data, but when I submit my form, I can't see the updated value. Neither in Data.ListName property nor in Editing.ListName.
I also tried:
<input type="text"
data-link="{:Data.ListName} linkTo{:Editing.ListName}
id{:'txtListName_' + #getIndex()}" >
<input type="text"
data-link="{:Data.ListName} linkTo=Editing.ListName
id{:'txtListName_' + #getIndex()}" >
But none of this works. The documentation is unclear regarding my issue.
What's the correct syntax ?
Ok, I managed to find the correct syntax, which is :
<input type="text"
data-link="{:Data.ListName linkTo=Editing.ListName:}
id{:'txtListName_' + #getIndex()}" >

Adding fields dynamically to Share form

I want to add a text field for each file that is added to the attached package items in alfresco to write notes regarding each file, is it possible to do?
I have implemented something that could be reused for your use case.
You can define a property with multiple values that will contain the list of notes associated with each attachment.
There is a simple trick to post a property with multiple values: add "[]" to the name of the property. For example:
<input id="template_x002e_edit-metadata_x002e_edit-metadata_x0023_default_prop_someco_notes_0"
name="prop_someco_notes[]"
tabindex="0"
type="text"
value="Meeting minutes"
title="Notes"
noderef="workflow://...."
>
<input id="template_x002e_edit-metadata_x002e_edit-metadata_x0023_default_prop_someco_notes_1"
name="prop_someco_notes[]"
tabindex="1"
type="text"
value="Meeting minutes"
title="Notes"
noderef="workflow://...."
>
As you can see, the name of the input ends with []. Both input textfields have the same name.
The Alfresco Form Engine will consider these two inputs as the value for the property with multiple values: "someco:notes".
The bigger problem is that you need to generate this html with some smart javascript and free marker template.
You can write a custom free marker template to render the initial html: if a user opens a task on which documents have been already attached, you will need to generate the list of inputs using a custom control (you can of course start from textfield.ftl).
It won't be easy to generate the initial list because unfortunately Alfresco returns the list of values as a single comma separated value.
You can customise the webscript that injects the model in the free marker template "org.alfresco.web.scripts.forms.FormUIGet" to pass an array instead of a csv.
A quicker and dirtier solution is to split the csv value. In share-config-custom.xml, you can specify what textfield.ftl show use as a separator instead of the comma.
When a user adds/remove elements from the package, you can intercept the update and add/remove the correspondent note. Notice that I have added the filed "noderef" to each input so it is possible to know the relation between the notes and the nodes in the package.
UPDATE:
For the associations (used for example to define the package in a workflow task), Share uses a javascript library called "object finder" (or "object picker"). This library fires an event called "formValueChanged" that you can intercept:
YAHOO.Bubbling.fire("formValueChanged",
{
eventGroup: this,
addedItems: addedItems,
removedItems: removedItems,
selectedItems: selectedItems,
selectedItemsMetaData: Alfresco.util.deepCopy(this.selectedItems)
});

Resources