Hi say I have two text fields. I want to have just one maxlength for both of them. Wherein, for example 300 is the maxlength. And that is for both text fields. Is it possible to have 1 maxlength for multiple fields?
Edit:
You will need to use jquery/javascript and client side validation. As a starting point
Something like
$('#text_field_1, #text_field_2').blur(function(){
if($('#text_field_1').val() + $('#text_field_2').val() > 300){
alert("Text Field max length has been reached");
}
});
Building on that example you'll want to have a listener on form submission $().submit that will return false, show an error message, and stop submitting the form if the max length is greater that allowed.
Related
I want to add validation in the entire column using excelJS in my LWC component. Below are my validation requirements:-
Text length entered in that column must be exactly 19 digits.
Text can be only alphanumeric.
I am not able to find the correct formulae for that to be inserted inside dataValidation. Please help me if anybody has anything. Thanks in advance.
const worksheet = workbook.addWorksheet('Sheet1');
worksheet.dataValidation.add(this.metadatRecords.Column_Range__c, {
type: 'custom',
allowBlank: false,
formulae: ['?'] // I need this to validate above requirements
error : "Please enter correct value",
errorStyle: 'error'
});
We have couple of masked textboxes Phone,Mobile) with proper masking but can't able to set the length validation. display:none is set automatically which bared validation message to be display over UI. Please help.
It is better to use data annotations in your model to set length for your input. If it is digits use something like:
[StringLength(int.MaxValue, MinimumLength = 7)]
If it is string use something like:
[RegularExpression(#"^(?:.*[a-z]){7,}$", ErrorMessage = "String length must be greater than or equal 7 characters.")]
Google Forms - I have set up a google form and I want to assign a unique id each of the completed incoming form inputs. My intention is to use the unique ID as an input for another google form I have created which I will use to link the two completed forms. Is there another easier way to do this?
I'm not a programmer but I have programming resources available to me if needed.
I was also banging my head at this and finally found a solution.
I compose a 6-digit number that gets generated automatically for every row and is composed of:
3 digits of the row number - that gives the uniqueness (you can use more if you expect more than 998 responses), concatenated with
3 digits of the timestamp converted to a number - that prevents guessing the number
Follow these instructions:
Create an additional column in the spreadsheet linked to your form, let's call it: "unique ID"
Row number 1 should be populated with column titles automatically
In row number 2, under column "Unique ID", add the following formula:
=arrayformula( if( len(A2:A), "" & text(row(A2:A) - row(A2) + 2, "000") & RIGHT(VALUE(A2:A), 3), iferror(1/0) ) )
Note: An array formula applies automatically to the entire column.
Make sure you never delete that row, even if you clear up all the results from the form
Once a new submission is populated, its "Unique ID" will appear automatically
Formula explanation:
Column A should normally hold the timestamp. If the timestamp is not empty, then this gives the row number: row(A2:A) - row(A2) + 2
Using text I trim it to a 3-digit number.
Then I concatenate it with the timestamp converted to a number using VALUE and trim it to the three right-most digits using RIGHT
Voila! A number that is both unique and hard-to-guess (as the submitter has no access to the timestamp).
If you would like more confidence, obviously you could use more digits for each of the parts.
You can apply unique ID numbers using an arrayformula next to the form data. In row 1 of the first rightmost empty column you can use something like
=arrayformula(if(row(A1:A)=1,"UNIQUE ID",if(len(A1:A)>0,98+row(A1:A),iferror(1/0))).
A few comments regarding the explanation provided by #Ying, which I will try to expand, as it is very good.
> Column A should normally hold the timestamp.
In my case, it is date+time stamp.
> 4. Make sure you never delete that row,
even if you clear up all the results from the form
That issue can easily be avoided by placing the formula in the header like this
={"calculated_id";arrayformula( if( len(C2:C); "" & text(row(C2:C) - row(C2) + 2; "000") & RIGHT(VALUE(C2:C); 3); iferror(1/0) ) )}
This formula provides an string for one cell, and a formula for the next one, which happens to be an array formula which will cover all the cells below.
Note: Depending on your language settings you may need to use ";" or "," as separator among parameters.
> 5. Once a new submission is populated,
its "Unique ID" will appear automatically
Issue
And here is the issue I see with this solution.
If the Google Form allows responders to Edit their responses, the date+time stamp will change and so the calculated_id.
A workaround is to have 2 columns, one is the calculated_id and the other will be static_id.
static_id will take whatever is on calculated_id only if itself has no data, otherwise it will stay as it is.
Doing that we will have an ID that will not change no matter how many updates the response experience.
The sort formula for static_id is
=IF(AND(IFERROR(K2)<>0;K2<>"");K2;L2)
The large one is
={"static_id";ArrayFormula(IF(AND(IFERROR(M2:M)<>0;M2:M<>"");M2:M;L2:L))
}
M or K -> static_id
L -> calculated_id
Remember to put this last one on the header of the column. I tend to change the color to purple when it has a formula behind, so I don't mess with it by mistake.
Extra info.
The numeric value from the date/time stamp differs when it comes from both or just one. Here are some examples.
Note that the number of digits on the fractional part differ quite a lot depending on the case.
I want to manipulate float numbers in gsp, here is what i want:
If the number has a 1.* i want it to show the dot, but if it ends with zero i dont want it to show the dot and zero.
like this:
Score: 1.5
Score: 1
Score: 2.1
Score: 3
The score variable is a float number and it is an input field on the gsp that loads the number and it can be changed.
But the real problem is, how can i see if the number has decimals?
There is already a taglib for formating numbers: (g:formatNumber)
I think something like this should work:
<g:formatNumber number="${score}" type="number" format="###.##"/>
But...if that doesn't work...
I would say write your own custom taglib. If it is something that is going to be used multiple times, why loop through a list of objects in your controller, change the float to a string just to display it? Let the page decide how to show it in the proper context.
Or
Add a transient field to the domain object (String scoreDisplay) and then have getScoreDisplay() return the value of score as a string, formatted how you want.
Well, I'd suggest you to format the number in your controller - before it gets to your gsp. That way you have more control over the number format. Once you're in the gsp, you have to use a grails' decimal number format or make your own taglib to format (since the number of fractional digits changes in your case).
I have a repeating field (say size 10) in my Filemaker database and try to fill it say with the Values 1..10.
I now want to use "Auto-Enter Calculation" to fill the field:
Case(
RepField = 1; 1;
RepField = 2; 2
)
But the field does not contain any values. How do I fill the field based on a calculation?
An auto-entered calculation cannot set values in the other repetitions. You'd need to use a script trigger or a button to call a script to set the repetitions on record creation.