I’m still debating whether I want to do this or not but what I’m considering is preventing users from entering hyperlinks into a HTML form in my app. This is to avoid spammy links from showing up for other uses of the app since the app is based on user generated content.
This is a Rails app, so I could do some backend validations on the model after the form is submitted by the user.
But I was wondering whether it might be preferable to perform the check in jQuery/JavaScript before any submission takes place. This way the user could be notified immediately without any backend processing.
Which would be preferable here – client-side or server-side validation?
You only have control over data when it arrives at your server. If you use JavaScript to try to strip out spam, then spammers are just going to turn JavaScript off.
Build a server side solution.
Once you have that, think about duplicating the work client side to make things nicer for users.