I'm terrible with Regular Expressions but I believe in this case I must create one.
Basically, a user needs to type a date of format: MM/DD/YYYY into a TextInput and I need to verify it.
Can anyone point me in the direction of those old Flex regular expression testers that I can no longer find, please?
Thanks!
UPDATE:
Here's the regular expression just in case it'll help someone:
var pattern:RegExp = /^(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.](19|20)\d\d$/;
Grant Skinner has regexer, I think thet's what you are looking for
http://gskinner.com/RegExr/
regexpal is pretty decent too
http://regexpal.com/
\d{2}/\d{2}/\d{4} for DD/DD/DDDD
\d\d?/\d\d?/\d{4} for D/D/DDDD and DD/DD/DDDD
Rather than using regular expressions (which are perfectly fine, they can just get messy), you might consider using the Flex DateValidator or a Flex 3 DateField control. Both of these methods will make sure you end up with a valid input with little effort on your part.
There is an example of how to use each class found at the bottom of the pages I linked to.
Related
Can I sort class properties and methods alphabetically.
I found that: https://plugins.jetbrains.com/plugin/9883-intellij-idea-properties-sorter
Is there any similar for PhpStorm?
First, to provide an answer to the question: Arrange your code automatically with PhpStorm (re)arranger.
To create a new rule, click the Add rule button in the upper right corner of the rules list. Configure it by type and modifier, add a name rule (like “init.*” or “*Test”) and/or set order type, if needed.
Now, in case someone is looking to sort selected text alphabetically, like I was trying to do, this might be able to help you: String Manipulation.
I wanted to select some text (like class imports in TypeScript) and order it alphabetically. I tried with the built-in code rearranger, but found it didn't work for just this simple purpose.
Source: How to sort text lines?
I have a rather stupid question, but I would like some input on the issue.
On some websites you have a date input field, which has a placeholder in the form of mm/dd/yyyy.
However, when you start typing, the characters are getting replaced one by one, like 02/3d/yyyy.
So its not a placeholder but some sort of dynamic input already. My question is, how is this generated? Is this a javascript library (jquery, angularjs etc.) or any other feature im not aware of?
Thanks for your help, I tried finding appropriate code online but nothing did the function described above.
I mean of course you could program in JS an event listener on keypress, and depending on the input you adjust the field accordingly, but I wonder if there is an easier way to do so!
You can create the mask by following this guide: https://github.com/RobinHerbots/Inputmask
I'm trying to read and set Excel cells values with Cells(1,1). I was successful with reading this value. But I've seen code with Cells(1,1).Value(). So when should I use the notation itself: Cells(1,1) and notation with .Value() (Text()/Value2())?
The default property of Cells in VBA is Value. There's no difference in using it vs not using it.
I prefer to explicitly define the Value property though for the sake of debugging and helping others who may read my code in future as it is a clear indication of what the code is trying to achieve.
Sadly, this isn't as cut and dry as I had hoped. Over the past few weeks I had been researching the use of jQuery with CRM. While it's nice and dandy for style alterations, I couldn't find any examples that are closer to business logic.
For example, today I needed to alert the browser if one of 4 fields were empty. Two were date fields, one a picklist and one a checkbox (bit). I thought that calling $("#formElement").val() would have gotten the value, and in some cases it did, such as the picklist after I parsed it as an int. However, the date fields always returned an empty string.
Looking through the CRM form HTML, I see that "#formElement" isn't always the ID of an input for a CRM form element. Case in point, the date fields had ID="DateTime" (or something similar). At this point, I had thought that I will need to create a filter that will take the table that contains #formElement as it's ID and look for the value of the first input in that table, but at that point using crmForm.all.formElement.DataValue just seemed easier.
I'm sure someone here has a solution for this (and maybe some explaination of how CRM Forms are written to help with a filter), and it really stinks not being able to install add-ons for Internet Explorer here at work. Thanks for any and all help.
Use jQuery to select the form itself (either by its ID or just by $(form)) and then iterate over its children that are input text fields. I haven't done this for a form before but it might work for you.
For anyone else who is looking for an answer, I have figured it out to a managable degree. Unfortuantely, I haven't been able to use CSS selectors to shorten attribute names, but I have been able to utilize jQuery to cut down on time. If you'd like to use a CRM 4 attribute with jQuery, it looks like this:
$(crmForm.all.new_attribute).bind("click", function() { ClickFunction(); });
What I was really gunning for was chaining, because there are plenty of times when I need to null a field, disable it, and then force it to submit. A little bit of magic and this:
crmForm.all.new_attribute.DataValue = null;
crmForm.all.new_attribute.Disable = true;
crmForm.all.new_attribute.ForceSubmit = true;
Becomes:
crmForm.all.new_attribute.dataValue().disable().forceSubmit();
I hope this helps some of you guys out!
I need to validate a date/time field on a webpage but want it to do it without reloading the page and would like 'instant' feedback for the users.
What's the best/easiest solution.
BTW: easiest scores 65% of total points
Edit:
What if best was 65% of total points?
If you would like to use JavaScript then it has built in date validation functions. However, if you do not want to go the JavaScript route, you could change the UI to dropdown controls which would limit the users ability to enter invalid data. You would still need to check server side to ensure nobody submits Feb 30th.
Check out this javascript date validation function.
It uses javascript, regular expressions and the 'onblur' event of a text input.
#David H. Aust
Using onblur for validation is problematic, because some folks use the enter key, not the mouse, to submit a form. Using onblur and the form's onsubmit event in conjunction could be a better solution. Back when I did JS validation for forms a lot more, I would run against keyup events. This gave the user instant feedback on whether or not their entry was correct. You can (and I did) also put checks in place so that the user doesn't receive an "incorrect" message until they've left the field (since you shouldn't tell them they're incorrect if they aren't done yet).
I would recommend using drop-downs for dates, as indicated above. I can't really think of any reason not to--you want the user to choose from pre-defined data, not give you something unique that you can't anticipate.
You can avoid February 30 with a little bit of Javascript (make the days field populate dynamically based on the month).
#Brian Warshaw
That is a really good point you make about not forgetting the users who navigate via the keyboard (uh, me).
Thanks for bringing our attention to that.
A simple javascript method that reads what's in the input field on submit and validates it. If it's not valid, return false so that the form is not submitted to the server.
... onSubmit="return validateForm();" ...
Make sure you validate on the server side too, it's easy to bypass javascript validation.
If you're using ASP.NET, it has validator controls that you can point to textboxes which you can then use to validate proper date/time formats.
There are a couple of date widgets available out in the aether. Then you can allow only valid input.
I've used this small bit of js code in a few projects, it'll do date quickly and easily along with a few others.
Link
Looks like there's a great video about the ASP.NET AJAX Control Toolkit provides the MaskedEdit control and the MaskedEditValidator control that works great. Not easy for beginners but VERY good and instant feedback.
Thanks for all the answers though!
asp.net
Unfortunately I can't accept this answer.