Saving only Integers in an inputfield via code

I need to save integers in a variable through inputfield but i dont know how and i have searched all over the internet but i cant find any solution to this problem
here is an example of what i mean

public var number : int;
public var inputField : InputField;

function Start()
{
inputField = GetComponent(InputField);
}

function Update()
{
number = inputField.text; //i cant do that because its not possible to save string into an int variable but thats basically what i mean… saving Integers into an int vriable from an InputField…

i have no clue how to do… would like to get some help from you guys :slight_smile:

}

You need to parse your string to an int. Lucky for you, you probably won´t have to write code to do that all yourself, here is a method I found for javascript: