Where to write a jquery script for a registration form page which created using webform module in Drupal 7?
First off, as rooby very accurately suggested in the comment section, you should not tamper with the Bartik theme directly. You have many possibilities on where to include a js script. You can read all of them in the relevant documentation in drupal.org.

The closest to what you describe is to subtheme Bartik and put all necessary js there, or even create a small custom module.

Apart from that, jQuery in Drupal uses the noconflict mode. Try to avoid the dollar sign but rather call jQuery. Although in your particular code should be ok as it is, there may be other instances in your script using $ that would prevent it from working. More on that here. Check your browser for js errors.

Last, there is no way for us to evaluate your jQuery code if it works properly or not as we do not have the produced HTML output nor the context of your provided js code.