Validation of paper-inputs that are not required - polymer

I am building a search request form, where the user may or may not fill in filter fields that he wants to narrow the search down by. But if he does fill in a field I want to validate it.
For instance, this search form has a "date of birth" field, so if anything is entered into this field, I need to validate its a valid date.
Unfortunately, in single stepping through the code, a <paper-input> field that does not have the required attribute cannot be validated, yet if I do put a required attribute on the field, it checks for an empty string value before calling my validator and says the form is invalid if this happens to be one of the unused fields.
Is there anyway round this conundrum?

Related

Date time parameter in SSRS

I have a report which requires user to type the start date and also allow them to choose from calendar. I was wondering if its possible to enter the date as a string. Right now, I have a text field with calendar and I would like the user to enter date[06302015] instead of [06/30/2015]
can we omit the dashes and still have the report format it to date?
The type of a parameter can be changed from Parameter Properties like below.
This will remove the Calendar and it will be only a Text box.
Change your parameter type to "Text".
Add a second "Hidden" parameter (as Date/Time data Type) that takes the LAST_DATE_EDITED as an input into the 2nd parameter's default value using the expression: =DateValue(Mid(Parameters!LAST_DATE_EDITED.Value,1,2) & "/" & Mid(Parameters!LAST_DATE_EDITED.Value,3,2) & "/" & Mid(Parameters!LAST_DATE_EDITED.Value,5,4))
(Not tested, but it should be close)
Then use the 2nd parameter in your report instead of LAST_DATE_EDITED.
If the user inputs an incorrectly formatted string of numbers, uses text, etc., SSRS will throw an exception.
IMO, this isn't the most elegant solution and it demands user input that is prone to errors. Not what I would implement (I would have the users use the built in DateTime picker and train them to use valid separators such as periods, slashes or dashes or just use the calendar control).

Allow users to input dashes to numeric field but then automatically delete dashes

I have a numeric field that I'm having some problems with. Users will be inputting a 6 digit number formatted as ##-####, but since it's a numeric field, they can't enter the dash. (unless there's a blindingly obvious solution I missed, which is entirely possible). I have it formatted to present with the dash, and I didn't think it would be a huge deal for users to just not input the dash, but my testers tell me it's very off putting to be reading a number with a dash and then not enter in a dash. I tried using an input mask, but I don't like how when you enter the control it doesn't automatically start at the beginning of the field.
Is there a way to allow the user to enter dashes into the control, and then in the before update event, it deletes all the dashes? I have a bunch of data validation for what ranges of numbers are acceptable, so I don't think I can convert it to a string field.
You will need a combination of InputMask, Format, and code-behind as shown here for entering a time:
Entering 24-hour time with input mask and full validation
Entering ISO formatted date with input mask and full validation
You should be able to modify the examples to fit your need.

Thymeleaf HTML5 long variable issue

I am new to Thymeleaf and HTML5.
I have a variable order number of data type long.
There is an input text field in the HTML for searching order number (assigned to order number variable), which always initialise to zero everytime when we load the HTML page.
Also, I am getting the error when I manually empty the filed and submit the form to fetch record from database.
My requirement is to have this field empty because this is an optional field. It can be zero/null/doesn’t contain any value.
Sample Code Snippet: <input type=“text” th:field=${order.ordernumber}>
Please advise on how to get this order number variable (long data type) without any default value being set.
It depends on your model. If there is 0 and this is the default for long this will shown in the view. If the ordernumber can be null or empty you should use Long.
This is only an assumption. To give you a detailed answer you must provide more information.

Using an expression in a numeric form control

I have an Access form with a textbox bound to a currency field in a table. As expected, anything other than a numerical entry generates an error. Occasionally, users need to enter several amounts and have those added together and the result entered into the currency field.
To accomplish this, I would like users to enter an equal sign followed by a valid arithmetical string which would evaluate to a number exactly as they would in an Excel cell. For example, if a user enters "=5.31+2" I want the field to evaluate to "7.31" and use that as the value passed to the table when the record is updated or saved. The current workaround is to use the Calculator application but that isn't the ideal solution.
I tried the following code and applied it to both the BeforeUpdate and OnLostFocus events of the textbox (named "tbxTotal_Paid") but neither worked. I simply got "The value you entered is not valid for this field" error.
Dim charCt As Integer
Dim evalStr As String
If Left(tbxTotal_Paid, 1) = "=" Then
charCt = Len(tbxTotal_Paid)
evalStr = Right(tbxTotal_Paid, charCt - 1)
Me.tbxTotal_Paid = CCur(evalStr)
End If
Is this simply applying the code to the incorrect event or is this a coding issue? Any assistance is appreciated.
For me your code looks fine but you might put it in the wrong place.
Like you said Acess is giving you this error because the textbox is bound to the currency-field. So it will never accept non-numerical values because the value-checking code fires even before the before_update-event.
I think the best solution would be to hide your bound text box using Me.tbxTotal_Paid.Visible = False and creating a surrogate textbox which is not bound. You put your code in the beforeUpdate-Event or Change-Event of your surrogate. At the end you should check your final result with IsNumeric(). That way your surrogate textbox writes only correct values to your bound hidden textbox and only numbers arrive at your table.
An alternative would be to change the currency column to a string-field but this would not be wise because of potential wrong data in your database.

MSAccess Change Date Value Before Validation

In a grid I have a date/time field where I would like the user to be able to type in short-hand formats for dates and times. For example, if they type in "435p" and then focus off of the cell they get the message "The value you entered isn't valid for this field.". Instead, I want to trap a pre-validationevent and change it to "4:35pm" for them.
What event can I use?
I've tried:
LostFocus & BeforeUpdate: too late (validation fires before event)
Dirty & OnChange: too early (they haven't left the cell yet)
Or is there a way to turn off the native validation rule that is checking for date formats?
You could use an additional text field without formatting (or with your very own format). Then show this instead of the datetime-field and update the date-time field with your code.
Not very pretty, but if you always format the input to a proper time string on before-update and never access this field (but rather the real date-time field) you should be ok. You could even name the field Helper_DateTime or somesuch, so you are never tempted to access the field from anywhere else ;)