Category

Java Script

Category

Get selected Text and Value of DropDownList in OnChange event using JavaScript and jQuery Select Car: <select id=”selectcar”> <option value=””></option> <option value=”BMW”>Apple</option> <option value=”TATA”>Mango</option> <option value=”MARUTI”>Orange</option> </select> <script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js”></script> <script type=”text/javascript”> $(function () { $(“#selectcar”).change(function () { var selectedText = $(this).find(“option:selected”).text(); var selectedValue = $(this).val(); alert(“Selected Text: ” + selectedText + ” Value: ” + selectedValue); }); }); </script>

<!DOCTYPE html> <html lang=”en”> <head> <meta charset=”UTF-8″> <meta name=”viewport” content=”width=device-width, initial-scale=1.0″> <meta http-equiv=”X-UA-Compatible” content=”ie=edge”> <title>Javascript form validation</title> </head> <body> <script> function validateform() { var name = document.singinform.name.value; var password = document.singinform.password.value; if (name == null || name == “”) { document.getElementById(“error”).innerHTML = “Name Can’t be blank”; return false; } else if (password.length < 6) { document.getElementById(“error”).innerHTML = “Paasword must me 6 digit”; return false; } else if (password == “password”) { document.getElementById(“error”).innerHTML = “password could…