Custom validation on existing Drupal form

Share

validationCustom validation on existing Drupal form

Hello folks, How are you doing? Thank you for your comments and queries on other topics I have written. There were queries on custom validation on existing Drupal form. So here is the post for you 🙂

Below is how we add custom validation on existing Drupal form. for example we want to add form validation to user login form, as this form is in Drupal’s core module we are not supposed to hack that module. So we need to create a new custom module say for example my_module. (I am assuming you know Drupal module development or comment below if you want me to write a blog on Drupal module development :))

Ok, so we have a module named my_module. Now we need to implement hook_form_alter to add a custom validation function to validate user login form, below is code snippet to do that.

Above code will look for the function validate_this_form() in your module when the form the user form is submitted.

So, lets implement that function and restrict some login names (Just to know how it works). Lets add if condition in function to check user name and set error message accordingly.

Above function will be executed and set validation error message for the form if username used is ‘sachin’

Below is how the error message gets added through our above function where username ‘sachin’ is checked.

custom validation on existing Drupal form

Please feel free to ask queries in comments or contact me using contact form on this site. I will be happy to help you out. Thank you for reading this post and see you again later with new post. 🙂

Or, please login using google or facebook and create a forum topic to get your query answered in few hours here http://www.learn-drupal.in/forums/forum/drupal-forum-post-installation

Thank you,
Sachin

362 views

Backlinks to my website: How do I find backlinks

Share

sachin

I am writing this blog because there were queries asking how can I find backlinks to my website.

Backlinks to my website

We all are curious to know what are the pages or domains linking to our website or to some page on website. There are some free tools advertising that they do this but i don’t recommend all of them. Google webmaster is the best free tool to do this. There are many other cool features Google webmaster provides, ‘Links to your site’ is one of the features.

You just need a google account to login to webmaster tool.

backlinks to my website

This is how you see your website links being linked from other websites. You can find those websites by clicking on these links.

So to get started with this, you first need to add your website to google by following steps below.

Adding website to google

1. Go to http://www.google.com/webmasters
2. Login to google webmaster by using your google account.
3. Click on “Add property” button to add your website to google.
backlinks to my website
4. Enter your websites URL in the box and submit the form.
5. After adding your website google will ask you to verify the ownership of your website, just follow the instructions to verify your websites ownership and you are good to go. Read more

667 views

How to earn affiliate commission from your blog or website

Share



If you are willing to make your blog make some money then you are at the right place where you will learn how you can earn affiliate commission through your blog.

First, you need to have a blog hosted on some good web hosting server like iPage. I recommend WordPress for your blog as there are plenty of freely available plugins which will help you make your blog SEO friendly and have your genuine content ranked top in search engine results.

Write your blogs as simple as possible, have some images in it.

1. Affiliate

You can become an affiliate of one, or of many companies in various domains out there. e.g ipage.

Register with ipage as affiliate at http://www.ipage.com/affiliate/gettingstarted.bml Read more

1,823 views