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.")]
Related
What I am trying to do is get the maximum from a row containing data which is of the form "x kg" where x is an integer but overall this forms a string. The issue is that running a =MAX(C5:AA5) over this returns 0 (for obvious reasons).
I thought about using another formula =LEFT(C5, LEN(C5) - 3) but the issue with this is that it only works for a single cell.
How can I (using a script if necessary), get the maximum value in the row knowing the row is only strings with integers in string format in them?
My rows look something like this: (note that commas represent another cell)
"20 kg", "30 kg", "40 kg", "50 kg", ...
You could create a custom number format instead of adding the text "kg". Select Format > Number > More Formats > Custom Number Formats > and enter 0 "kg" in the text field. Now that format will be saved for you, you can apply it to your whole row and get the MAX() formula working correctly for you while keeping your visual format.
shorter solution:
=ARRAYFORMULA(MAX(VALUE(SUBSTITUTE(A20:A, " kg", ""))))
=ARRAYFORMULA(MAX(IFERROR(VALUE(REGEXEXTRACT(A20:A, "\d+")))))
even shorter:
=ARRAYFORMULA(MAX(IFERROR(SPLIT(A20:A," "))))
I have a [DataType(DataType.PhoneNumber)] on a String field in my view model. When the phone number is displayed, however, it is rendered as a simple string with no formatting.
Another field in my view model has the [DataType(DataType.Url)] attribute and it renders correctly as an HTML element.
I have two questions then:
Why does the DataType.Url decorated field render correctly while the
DataType.PhoneNumber field looks like an ordinary string of character with no phone-specific formatting?
How can I get the PhoneNumber to render as a valid phone number
(i.e., something like (xxx) xxx-xxxx. If you tell me I must use a
DataFormat attribute with a DataFormatString, then what's the
point of even having a DataType.PhoneNumber?
For your first question, Url's have a specific syntax that if not followed will not be a correct url.
Phone numbers do not have any specific format. in the US alone you could have
xxx-xxx-xxxx
(xxx) xxx-xxxx
(xxx)xxx-xxxx
xxx.xxx.xxxx
1(xxx) xxx-xxxx
Then you get into international numbers with country code prefixes.
010 64 3 477 4000
0011 64 3 477 4000
+64 3 477 4000
All of these are valid phone numbers
input="tel" allows you to embed a phone number so that in a mobile(phone) browser, you can click on it and it will pre-populate the phone number in your dialer.
As for the data-annotations, they render the correct html they will have the correct html5 type tags. It up to the browser to actually implement what it will look like on the screen or interpret how it should be validated.
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.
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.