Hello Sabahat,
Yes you are on right path. You can use the "getFormType" API which will provide form type i.e. Create, Update, Read only, etc.
And as per your requirement you can perform your task of lock and unlock field.
Basically make this fields as locked by default and Run a JS which will make this fields as Unlocked for Create form Type.
Please refer below JS which will help you to implement your requirement.
itsfascinating.com/.../
learntoinspire.ca/.../
Thank you,
Amit Katariya