1

Here is my code :

In My MVC View:

  @
  {
  var datefrom = Model.Vehicle.First().DateFrom.ToString("MMMM    yyyy")
  };

In my AjaxBeginForm:

    {
     <input type="hidden" id="vehicledatefrom" value=@datefrom/>
    }

My jquery:

          var datefromto= $('#vehicledatefrom').val() ;



   After debugging with break point, the datefrom value is = " July 2006";
   But when I am calling the val() in jquery I am getting only "July".
   What's the wrong in my code why I am not getting complete value "July 2006";
   val() is not taking after the space why any suggestions thanks

1 Answer 1

2

That is because you have not enclosed the value attribute using quotes.

And it seems to taking only the first part of the value before it is encountering a space which it thinks is the end of it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.