Domain name Avaliability checker


i want this type of snippet code to check is there domain is available or not? can anyone help me with this.

image description:

if i put any domain name it will show the domain is available or not. and if not i want to put url or but now button at same place to buy the domain from any domain provider site.