I'm running into an issue validating 1 instance of my model medewerker_functie
.
Within that Model, I have 3 instances that are decimals. Two of them - uren
at 40.0 and fulltime_salaris
at 2200.00, are being validated correctly while the salaris
isn't.
In the process of handling the values within the Actionresult Create
, they are being received as strings due to JavaScript conversion:
onblur="$(this).val(parseFloat($(this).val()).toFixed(2))"
However, despite attempts to convert the values using parseFloat()
, the value for salaris
remains a string.
This is reflected in my code snippet:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include = "ID,medID,functieID,type_contract,startdatum,einddatum,aantal_uur,aantal_dagen,fulltime_salaris,salaris")] medewerker_functie medewerker_functie, int medID, int functieID, string contract, DateTime startDate, DateTime? endDate, String uren, int dagen, String fulltime, String salaris)
{
// Code implementation here
}
The confusion lies in the fact that fulltime_salaris
and uren
accept values properly, but not salaris
. The fields in question are specified as decimals in both the model and the database.
During debugging, it was discovered that the AJAX call returns the correct values but they remain as strings when processed in the backend code. This discrepancy has caused issues with validation.
EDIT
The AJAX call also confirms the initial issue with data types:
// Console log output and AJAX call code here