What is the best way to encrypt form data from client end javascript and decrypt at server side Java? I have to send user data from a form to server side and process it. But I would like to encrypt this information to make sure the information is safe.

I am using a random word Array as salt, another random word array as IV, userId as passphrase to encrypt the password.
Same salt and IV, password (without encryption) as passphrase is used to encrypt userId.

Salt, IV, userId (both plain and encrypted), encrypted password is sent to server side where the reverse operation is performed to decrypt the data.

But since passphrase is also available at client end, this doesn't seem safe. What is the best way to achieve this?
If you are not using SSL/TLS on the web server, any man-in-the-middle can tamper with the javascript code as it is pushed from the server to the client. At that point, an attacker can disable any client-side protections you have added. So, without SSL/TLS, anything you do is basically useless.

Now, once you enable SSL/TLS on the server and force users to connect via that secure connection, all information is protected in transit already, so no additional protections are needed.

So, enable SSL/TLS on the server and force all connections to use that and you are good to go.