Hello everyone I would like to ask how to check value’s length from textbox ?
Here is my code :
@*<script>
function validateForm() {
var x = document.forms["frm"]["txtCardNumber"].value;
if (x == null || x == "" ) {
alert("First name must be filled out");
return false;
}
}
</script>*@
When I run my script yeap I got alert message but I’m trying to add property which control the texbox’ input length.
You could use
x.lengthto get the length of the string:Also I would recommend you using the
document.getElementByIdmethod instead ofdocument.forms["frm"]["txtCardNumber"].So if you have an input field:
you could retrieve its value from the id: