Getting and setting a text value property
To demonstrate how a text field’s property can be read and change the script below provides a simpleĀ html page with a single form.
In this example we use the “toUpperCase()” function which converts the value to uppercase.
code:
<html>
<head>
<title>
Read and change the text value property
</title>
<script text=”text/javascript”>
function myfunction()
{
var text_field = document.forms[0].myfield;
var make_upper_case = text_field.value.toUpperCase();
text_field.value = make_upper_case;
}
</script>
</head>
<body>
<form onSubmit=”return false”>
<input type=”text” name=”myfield” onChange=”myfunction();”/>
</form>
</body>
</html>
Leave a Reply
You must be logged in to post a comment.
