asp.net mvc 4 - Javascript "Expect ;" on int -


i keep getting "expected ;" error on 3 int variables (month, day, year) defining:

<script type="text/javascript">          function validatedateformat(input)    {      var values = input.value.split("/");      int month = parseint(values[0]);      int day =   parseint(values[1]);      int year =  parseint(values[2]);       if ((month < 1 || month > 12))       {        alert("month value: "+ month + " not valid month using mm/dd/yyyy format");        input.value = "";        return;      }       if ((string.valueof(year).length() != 4))       {        alert("year value: "+ year + " not valid year using mm/dd/yyyy format");        input.value = "";        return;      }       if(day < 1 || day > daysinmonth(month, year))      {        alert("day value: "+ day + " not valid day month value: " + month + " using mm/dd/yyyy format");        input.value = "";        return;      }    }; 

....

when try run page debugger in firefox throws:

syntaxerror: missing ; before statement

i don't understand problem is. if do, int month = 0 first line, still same error. using razor on asp.net mvc 4

you don't declare variable int in javascript.

change

int month = parseint(values[0]); 

to

var month = parseint(values[0]); 

(and of course 2 following lines too)

if want typed variables have @ typescript i'd suggest dive idiomatic js first.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -