Hi Hemalatha,
Unfortunately it is not possible to interact with the 'Required' form field attribute programmatically via JavaScript. I could suggest creating two fields, one required and one not required, and programmatically show/hide the appropriate field depending on the user's input.
Thanks,
Jason