I have to do image size validation using JavaScript. The sizes are provided as text, in the form nXn — e.g. “5X4” or something.
I have done a test for whether the provided size contains an “X”:
if(inputVal.indexOf("X")==-1)
{
$('#erSize').append("*Size should be (e.g) 6X4");
}
But this test accepts e.g. “aXg” also.
How can I check that the values entered either side of “X” are only integers?
1 Answer