Reputation: 35
Client Vs Server Script - for validating the following? From the database, a list of countries in world (India,America,japan,USA etc.,) are queried and stored in a list. Now, the user enters state name as text. This needs to be validated against the list of values. Where should this validation be written? Client or Server?
Upvotes: 1
Views: 882
Reputation: 915
You don't need a script for this case. You can have a Custom Record for the Countries and Custom Record for the States. State Custom Record will have a field for name of the State and another field that will source the the Country record which has a field for the name of the country. Once the custom records are created then you can now create the field from the record you want let say Contact record. Create a field Country which source to the Country custom record then another field for State which source to the State custom record and put a filter on based on the Country Field. This way, when the user selects the Country the list on the State will only be populated with the state that has the same country from the state custom record.
Upvotes: 2
Reputation: 1826
This is something you can do on servers side so you avoid having problems with the user. If the users is typing some whole wrong information, where'd you like to have the errors in a logfile on the client side where the user have to contact you first or would you like to have it server side so you'll see what's going on?
What matters aswell is the extensibility of your software, you can easy continue working on your code server sided otherwise you would need to update the validation ofc.
What's importat is that the Validation is cased locally (client) so you need to define the validation server sided but it will run locally.
You will try to use the input from the user, and do a list.Contains
method or another validation method.
Hope you can work with this :)
Upvotes: 0