How can I create a date field by HTML5 Pattern (DD.MM.YYYY) - html

I have that code:
(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))
Checks that
1) the year is numeric and starts with 19 or 20,
2) the month is numeric and between 01-12, and
3) the day is numeric between 01-29, or
b) 30 if the month value is anything other than 02, or
c) 31 if the month value is one of 01,03,05,07,08,10, or 12
It's from page http://html5pattern.com/Dates
I tried to move some part of code, but then this code doesnt work... Even I tried to find some instructions how can I do it. But I can't handle with it...
How can I get a result like with above code but in format:
DD.MM.YYYY
Also is there any possibility to add the dots in field that user can only input the numbers without dots?
(I mean that the dots will be there every time)
Thank you for help.
Sorry for my English.

I think this is something that you are looking for:
(?:(?:0[1-9]|1[0-9]|2[0-9])\.(?:0[1-9]|1[0-2])|(?:30)\.(?:(?!02)(?:0[1-9]|1[0-2]))|(?:31)\.(?:0[13578]|1[02]))\.(?:19|20)[0-9]{2}
Also tried some possible test cases and worked fine:

You can use an input mask plugin for some of what you are asking for instead I suppose.
One popular one that comes to my mind is Robin Herbots: https://github.com/RobinHerbots/Inputmask
You can find demos off his page here: https://robinherbots.github.io/Inputmask/index.html
Once you implement the plugin into your page, then it's just a matter of establishing the right input tags and jquery for them. For example:
Your phone number script would then be something along the lines of:
<script type="text/javascript">
$("#Phone").inputmask({mask: "999.999.9999"});
</script>
You should look up the documentation for it.

Related

How to highlight a range of selected months

I'm new to Angular. All the answers that i came accross are using jquery and javascript. Few weeks ago there was a requirement in my team that we need a month only picker. But the condition is that we cannot outsource the component from anywhere outside the organization. Not even bootstrap, material or primeng. So I decided to create a custom one from the scratch using HTML and CSS. Here is the screenshot:
app-monthpicker is a component and on top of it there is a parent component app-timeselector.
The monthpicker is working perfectly. But I'm not able to implement the logic for highlighting the selected range of months. All the solutions on stackoverflow and other websites are using jquery or js. But here We're talking typescript. I've created a minimal stackblitz and here is one more stackblitz created by one of the answerer. Can someone help me in this regard please. With HTML and CSS and Typescript only. I badly need someones help here. I want this:
You can see 6 months from the previous year and all the months from next year also. And they also need to be highlighted if they're in range. For now I need this for 2017 to 2025 only. I don't mind even if you hard-code these values for now.
PS: I'm afraid that my whole implementation is incorrect. Please correct me.
Ideally, for such a use case you should not re-invent the wheel and leverage a good library that solved this problem. But if you want to make your current code works for the use case here is what can be done:
demo: https://angular-zedvjx.stackblitz.io
implementation: https://stackblitz.com/edit/angular-zedvjx
At high level:
I used approach where overall months are represented by one large
Array (monthsData) since the use case needs to support months
selection across years and this way it is easier to iterate over it.
Then each month view is just a "slice" into this big array, so
switching between years is switching between the "views" (view here
is monthArray.slice(viewStart, viewFinish) )
Also introduced state for the range to keep track of it easier.
Update: wrote an article with cleaner implementation here: https://medium.com/better-programming/month-range-picker-in-angular-8-4ce93ef7d76b
I'll take another aproach. You has four variables:lboundMonth,lboundYear,uboundMonth and uboundYear.
I think that you can has some like, I put and example from october 2020 to febrary 2021
lbound:{year:2020,month:10,yearMonth:"202010"} //yearMonth it's the way yyyyMM
ubound:{year:2020,month:1,ueatMonth:"202101"}
Futhermore, you create an array with the month. As #Sergey say, we can create an array of months. But in my case, I'll take that was in the way
{monthName: "january",month:1,monthYear:202001}
So, when you change the year
month=arr.map((x,index)=>{
return {
monthName:x,
month:(index+1)
monthYear:displayYear+('00'+(x+1)).slice(-2)
})
You only need compare in the loop monthYear with lbound and ubound. Some like
<div *ngFor="let month of months>
<span [ngClass]="{'ubound':month.yearMonth==ubound.yearMonth,
'lbound':month.yearMonth==lbound.yearMonth,
'range':month.yearMonth>lbound.yearMonth &&
month.yearMonth<ubound.yearMonth
}"
(click)="click(month)"
</div>
When you click you has in
click(month:any)
{
const my={
year:this.displayYear
month:month.month
monthYear:month.monthYear
}
..asing to lbound or tbound
//you emit:
this.ouputToparent({
lbound:this.lbound,
ubound:this.ubound,
})
//or
this.ouputToparent({
lbound:{year:this.lbound.year,month:this.lbound.month},
ubound:{year:this.ubound.year,month:this.ubound.month},
})
}

SSRS custom number format

I am go to generate an excel file from SSRS, and
I want to format the number like this...
15 is displayed as 15
14.3453453 is displayed as 14.35
12.1 is displayed as 12.1
0 is displayed as 0
1 is displayed as 1
I can apply this in Excel but unable to apply in SSRS
[=0]0;[=1]1;0.##
Does anyone can suggest another way for me? Thanks!
am assuming that you want to know how to format numbers in SSRS
Just right click the TextBox on which you want to apply formatting, go to its expression.
suppose its expression is something like below
=Fields!myField.Value
then do this
=Format(Fields!myField.Value,"##.##")
or
=Format(Fields!myFields.Value,"00.00")
difference between the two is that former one would make 4 as 4 and later one would make 4 as 04.00
this should give you an idea.
also: you might have to convert your field into a numerical one. i.e.
=Format(CDbl(Fields!myFields.Value),"00.00")
so: 0 in format expression means, when no number is present, place a 0 there and # means when no number is present, leave it. Both of them works same when numbers are present
ie. 45.6567 would be 45.65 for both of them:
UPDATE :
if you want to apply variable formatting on the same column based on row values i.e.
you want myField to have no formatting when it has no decimal value but formatting with double precision when it has decimal then you can do it through logic. (though you should not be doing so)
Go to the appropriate textbox and go to its expression and do this:
=IIF((Fields!myField.Value - CInt(Fields!myField.Value)) > 0,
Format(Fields!myField.Value, "##.##"),Fields!myField.Value)
so basically you are using IIF(condition, true,false) operator of SSRS,
ur condition is to check whether the number has decimal value, if it has, you apply the formatting and if no, you let it as it is.
this should give you an idea, how to handle variable formatting.
Have you tried with the custom format "#,##0.##" ?
You can use
=Format(Fields!myField.Value,"F2")

MS Access VBA Cross tab report legend sort order

The problem is hard to explain ,
I have an access report with a stacked bar chart to show the percentage fills over time like the one in this example : Click here
The legend for the chart i have is a number followed by the name, for e.g
1-Mango
2-Apple
3-Banana
etc
I want to sort this according to the above format but when i have more than 10 items the 10-Pineapple comes before 1-mango when it should appear after 9-somefruit .
The underlying query for the access report uses a Cross Tab query in which the items are created as
Column heading:[PrefixPriorityNumber]&"-"&[FruitName]
I even used the Sort:Ascending but it still doesnt affect my custom ordering that i wanted to show.
I also tried to google "sorting alpha numeric strings" but this is clearly more than that.Any assistance is appreciated
The problem is you are getting a text sort. You need to format the prefix number.
Column heading: Format([PrefixPriorityNumber], "00") & "-" & [FruitName]
Either use another digit, as Remou suggests (01 instead of 1) or start using letters. A > 9, B > A, etc.

Something like a Date picker for numbers

I have two fields in my form : one is the limit and other is value. So if I enter 30 in the limit field, then in my value field I need to open up something similar to a date picker, which shows all numbers from 1-30 and user should be allowed to pick one or multiple values.
Is there a js library that I can use to achieve this?
Ive built it for you
http://jsbin.com/ehuke4/37/edit
How about using a slider? In HTML 5 you can use the below code. For browsers that do not support it you'll want to use some sort of alternative.
<input type="range" min="1" max="30">
jQuery UI has a nice slider too.

"." in query string messing up

I was working with queries that the data is being used for the meta description.
UPDATE cards SET meta_description = 'Amy\'s bugs address labels are printed on recycled label paper. Available in quantities of 30. Each label is 2.5 x 1 inch with rounded corners.' WHERE card_id = 'al007'
I have noticed though that the period after paper is shortening the meta description to just "Amy's bugs address labels are printed on recycled label paper." If I remove the period the entire description will show up then. Does anyone know how to solve this tiny dilemma?
I'm pretty sure that the issue is in whatever place you see the results. Most likely, there's a line feed after the period and your device does not support/show multi-line data. When you remove the period, you probably remove the carriage return as well.
Try escaping the period with '\'
Since you say, by removing period, the whole sentence is getting updated, I assume there is no problem with the column size.