Yes the funds with the online brokers are equally safe as with the funds with street side brokers, as long it is a SEBI registered broker.
Funds Lies in the Brokers account, and not with NSE.
Even in the case of fraud, NSE has a trust called "NSE
Investor Protection Fund" which will compensate your losses upto Rs. 15 lakhs. Similar trust's are also available with BSE and other exchanges also.
So if you lose money upto 15 lakhs, you will get it back. But, if you lose 20 Lakhs, then you will be compensated only upto Rs. 15lakhs only.
Don't just think that online brokers are Risky. Even Street side brokers like Nirmal bang, SMC Global, Indiabulls etc can also go bankrupt.
Remembered the 2008 Lehman brothers bankruptcy?