Solution 1 :

You can do it using serialize()

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    $("div").text($("form").serialize());
  });
});
</script>
</head>
<body>

<form action="">
  First name: <input type="text" name="FirstName" value="Mickey"><br>
  Password: <input type="text" name="LastName" value="Mouse"><br>
</form>

<button>Serialize form values</button>
body>

<form action="">
  First name: <input type="text" name="nm" value="Mickey"><br>
  Last name: <input type="password" name="password" value="Mouse"><br>
</form>

<button>Serialize form values</button>

<div></div>
</body>
</html>
<div></div>

</body>
</html>

Hope this will help you

Problem :

I have an HTML form

<form>

Name <input name=nm type=text">
Password <input name=pass type=password >

I want to send the value of both the field, how to do this using js

Comments

Comment posted by Barmar

You can use

Comment posted by Anshu

Hey thanks, it’s done , thankyou for your valuable time sir

By