Im working on an mvc3 application that will be deployed globally and have a question about phone numbers and validation.
I want to display a textbox that allows customers to insert their phone number correctly based on the machines settings.
I know I can apply all of my regex's onto the model's PhoneNumber field.
If a user is coming from the US vs the UK there are 2 different regexs to be used.
Lets say a US based user inserts an invalid phone number how can I tell the application only to validate the phone number using the US format based on the users culture not against the entire range of regex's?
I dont want the user to be told that his/her phone number is not formatted in UK format as that means nothing to them.
Hope this makes sense.
There are a lot more than two regexes.
For the UK alone there are are getting on for 10 or more different formats for telephone numbers and that doesn't take into account the different ways people can (and do) group the digits as well.
My answer to a different question shows the different formats.
You're best approach is probably to use other data on the form to try to validate the phone number rather than analysing the number itself.
Related
I have a google form where individuals are inputting two numbers via dropdowns: 1) Required Base Salary, 2) Total Target Compensation. Using app scripts I would like to have real time validation to insure that Total Target Comp is greater than or equal to Required Base Salary right after they make their selections. Is this even possible?
You can't interact with a Form answer until that answer is submitted. As a workaround, you could split the quizz into two forms. The first Form would include the Required Base Salary, while the second Form would ask for the Total Target Compensation based on the results of the first Form. As an alternative you could warn the user about the correct values on the question description (and send him an email warning about incorrect values after the answer is submitted). Additionally you could set up data validation rules to prevent bad values.
I'm working on a multi-tenant application catering to customers in different countries. When displaying measurement results, the display labels measurement values need to be in different languages.
Labels for measurement values received in one tenant will only need to be translated to that tenant's language (we assume that the users will be patients or employers that understand the same language).
What is a good strategy for storing/displaying translated strings? Should I perform translation when storing the values and add a custom value in code.coding or is it better to translate existing code.coding.display values when rendering the view?
FHIR is silent on whether you should translate before storing or when returning data. Do consider the ramifications on digital signatures regardless of approach (anyone adding translations after the instance is signed will break the signature). There's a standard extension for conveying the language of a string and translations of the string - see http://www.hl7.org/fhir/extension-iso21090-st-language.html and http://www.hl7.org/fhir/extension-iso21090-st-translation.html. These work on any string in a FHIR instance.
We currently have a Web Forms set up for our website and are looking to slowly convert this to MVC. Currently we store translations in a database. our translation table contains columns for each language and a sort of title. which we can identify the translation with(The primary key)
But it gets more complex when we actually may have different clients wanting different words for the same bit of text.
E.g. one will want it to read - Delivery Costs
And the next may want it as - Delivery Prices
So we then have a second CustomTranslation datatable which will be the same as the translation but also have a client ID number in it. If the user logged in and it looking for the Identify of the translation as "DeliveryCost" it will check to see if there is a record in the CustomTranslation table it will use that OVER the standard Translation table.
After which it will then pick the appropriate language the users wants.
Basically I need to be able to have our website translate depending on the users settings. And as well as the company they work for (our client)
The general method of localization uses resource files but we need to really keep them in the database. This produces a second problem which is when you try to declare Propertry Display Names and Validation Messages these also need to ability to have different text and/or translations but generally it expects a Static field which we would not have.
Whats the best way to go about solving this complex localization issue?
Thanks in advance. Steve
Problem 1 - Having the resources in the database
Use the approach used in this article for extending the standard resources into the database.
Problem 2 - Having custom localization per customer
No problem, the standard .net approach supports localization including a region or customer, just use i.e. en-US, en-US-Customer1, en-US-Customer2, etc.
A key part of my current project is users having the ability to see what other users live near to them. What is the best way to implement this?
I would just ask for country, state and city but because this will be international I can't have a fixed drop down list of states/administrative regions for each country, so if users spell the name of their state differently this will hinder my ability to detect that users live in the same state.
Say for example we have an the Swiss canton "St. Gallen". Some user will spell that as "Saint Gallen", others as "St Gallen" and so on. Which is obviously problematic.
Could I just ask for the zip code and use that? I've found some zipcode tools online but I'm suspecting they don't work very well. Has anyone used them?
Thanks for your asnwers.
Shouldn't you base your query on geographical data rather than administration one? I mean instead of comparing cities/zip codes just find people within, let's say, 5 km from current user location. And if you let every user to choose his/her location on the map, this will be as simple as choosing it from a series of drop-down lists or entering a ZIP code. Also there is an emerging geolocation HTML feature.
Querying such an information is different story thou. You'll probably gonna have to use GIS capabilities of your database: MySQL, PostgreSQL, Oracle and others.
Hi Sitepoint wizard people,
Say we have an admin application that has multiple users and various objects. What I'd like to do is control access within the object itself - that is, it will behave one way for one type of user, and another way for other users. For example...
Director Mike can override Reception user Sally's registration date. One would assume that Mike could set any date both in the past or in the future. Then we have Payroll user Steve who can also modify Sally's registration date, but only for dates in the past up until (for example) one year ago. To spice things up, then we have the HR Manager Mary who can also amend Sally's registration date, but only for dates from precisely 23rd June 2007 up until one month from now...
How can I program the access restrictions so that on the front end, the form control is restricted with a min and max date, and in the backend, the validator checks the entered date to make sure it falls between those dates? I'd obviously need to be able to tweak the min and max dates for each user type. Other objects might have different parameters - maximum amount on a discount field or days of the week for overtime, for example.
I've asked this question in different ways, but each time I get bogged down by the implementation. I'm currently developing it as a php/MySQL web-based application, but thoughts and comments from other platforms very welcome! This time I'm looking at first principles, so it doesn't matter what your background is, if you have any ideas, please let me know! What do you even call this type of access control...?
Depending of how you application is based, you could ask for credentials at the start of the application and depending on who is requiring access, you could load a different xml file containing different settings.
As for security issue, make sure that the different xml files can't be reached by the users.
Edit:
Since you are using MySQL you could do something like this.
Let's say you have a table of users that has those fields : UserId, UserName, RestrictionId.
And with a Restriction table that looks like : RestrictionId, FieldName, FieldCondition.
This way, in your php app, when a user is authenticated, you can go fetch the correct "Restrictions" on the field and apply them in your code. If it happens that you have multiple fields that require different rules then you can simply add them with the correct RestrictionId.
This DB design is far from perfect, I'm pretty sure you can do better
Since, you are already using MySql db. You can maintain the UserRole Master table details in DB itself. Load the user role data based on login, then you can easily validate the changes made by the user accordingly.