Compare first three characters of text box string value

Hi -
I'm trying to compare the first three digits of a textbox value to a fixed string.  I've tried to identify the first three characters by using the CharAt() function, but keep getting "object doesnt support this property or method' error.  Any suggestions?   Pnvalu value should be a string that looks like 'ABC123456'.   I need to compare the first three characters to make sure the user entered in the correct invoice number.

Code is part of a larger validation script.  Thanks for your help!  
function checkRadio(main)  {
var pnvalu = document.all.INVOICE.value;
var size = pnvalu.length;
var comp = "ABC"
var size3 = pnvalu.CharAt(size-3);
pnvalu = pnvalu.toUpperCase();

Open in new window

Who is Participating?
var size3 = pnvalu.substr(0,3);
var size3 = pnvalu.tostring.substring(0,3)
>>but keep getting "object doesnt support this property or method' error.
The method is "charAt()" - lowercase "c" for "char", but it will only return ONE character, not a substring.
>>var pnvalu = document.all.INVOICE.value;
document.all will work only for IE. I suggest you give your input field an id:

<input id="Invoice" name="INVOICE" .../>
and use:
var pnvalu = document.getElementById("Invoice").value;

Open in new window

MoJeaux39Author Commented:
Thanks for the Assist!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.