<!DOCTYPE html>
<html>
<head>
<title>Try jQuery Online</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("em").addClass("selected");
$("#myid").addClass("highlight");
$('#text1').change(function() {
var x = document.getElementById("label2");
if (x.innerHTML === "Last Name") {
x.innerHTML = "Last Name*";
} else {
x.innerHTML = "Last Name";
}
if ($('#text2').attr('required')) {
$('#text2').removeAttr('required');
}
else {
$('#text2').attr('required','required');
}
});
});
</script>
<style>
.selected {
color:red;
}
.highlight {
background:yellow;
}
</style>
</head>
<body>
<form>
<label for="text1" id="label1"> first name</label>
<p><input type="textbox" id="text1"/> Check Me to make the Text Box a Required Field</p>
<b>
</b>
<label for="tex2" id="label2">Last Name</label>
<input type="text" id="text2" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
<html>
<head>
<title>Try jQuery Online</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("em").addClass("selected");
$("#myid").addClass("highlight");
$('#text1').change(function() {
var x = document.getElementById("label2");
if (x.innerHTML === "Last Name") {
x.innerHTML = "Last Name*";
} else {
x.innerHTML = "Last Name";
}
if ($('#text2').attr('required')) {
$('#text2').removeAttr('required');
}
else {
$('#text2').attr('required','required');
}
});
});
</script>
<style>
.selected {
color:red;
}
.highlight {
background:yellow;
}
</style>
</head>
<body>
<form>
<label for="text1" id="label1"> first name</label>
<p><input type="textbox" id="text1"/> Check Me to make the Text Box a Required Field</p>
<b>
</b>
<label for="tex2" id="label2">Last Name</label>
<input type="text" id="text2" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
Comments
Post a Comment