Restrict input to number

I am using a math input to request a number input from students. I have added the following to the input in order to prevent students from just entering text:
errorMessage: when not(numericValue("\operatorname{mod}\left(${input.numericValue},1\right)") = 0) “Enter an integer.” otherwise “”

However, if they enter a number and then a variable, it will use the number and ignore the variable (or treat it as 1). ie. 3x ==> 3, 7f ==> 7.

Is there any way to force it to create an error message when the student includes a variable?

ETA: Here is a link to the file. The beginning slides all have cover text but I removed the cover text for slide 14 which has the code I’m struggling with so you can just skip ahead to that. The correct answer is 18. Super Secret Spy Missions • Activity Builder by Desmos

How about this instead?

errorMessage: when not(numericValue("\round(${this.numericValue})")=this.numericValue) "Enter an integer."
otherwise ""

Sorry. Didn’t work. It’s doing the exact same thing as my original code. So weird.

Try something like this:

errorMessage: when not(numericValue("\operatorname{mod}\left(${this.numericValue},1\right)") = 0) or isUndefined(simpleFunction(this.latex, "a", "q", "w")) "Enter an integer." otherwise ""

The only way is will return defined is if a student enters an expression with a, q, and w as variables. It’s a bit hacky and I bet there’s another way that’s preferred, but it should work.

That worked! Thank you.