I am using Forms on my umbraco 7.2.1 . On submitting the form it clears the fields.
Ex : I have 2 mandatory fields, Firstname and email.
When I fill the firstname field with the correct value but email is empty, and I click on submit button, the page reloads and clears the firstname field containing the correct values.
Can some one please advise on how to correct the javascript (which file to acceess) or any other solution.
To me it sounds like you maybe missed to include the jquery.validate plugin to your frontend, so it validate if a field is required. Try to see this documentation on how to repping frontend using Umbraco Forms.
i agree with Dennis. I would add that if your form is posting to a controller (server side validation), you must check ModelState and if you have an error make sure you pass the model back to your view:
[HttpPost]
ActionResult myAction(myModel formModel)
{
if (ModelState.IsValid)
{
//great, do stuff
}
else
{
//do something with the model state errors...
return View(formModel);
}
}
I think that you should mak the post as solved, so other can see what works for you and jump straight to the solution. Ff you donĀ“t know how to mark a post as solved I will explain it to you.
You have a green tick in the left side of the screen next to the avatar picture. You can mark the question as solved by tick the green tick, for the post that gives you the right answer to your problem. You can only choose one post as the solution.
Forms - issue
Hello,
I am using Forms on my umbraco 7.2.1 . On submitting the form it clears the fields.
Ex : I have 2 mandatory fields, Firstname and email.
When I fill the firstname field with the correct value but email is empty, and I click on submit button, the page reloads and clears the firstname field containing the correct values.
Can some one please advise on how to correct the javascript (which file to acceess) or any other solution.
Thanking you in advance for your help,
kusum
Hi kusum,
To me it sounds like you maybe missed to include the jquery.validate plugin to your frontend, so it validate if a field is required. Try to see this documentation on how to repping frontend using Umbraco Forms.
https://our.umbraco.org/documentation/Products/UmbracoForms/Developer/Prepping-Frontend/
Hope this helps,
/Dennis
Hi Kusum,
i agree with Dennis. I would add that if your form is posting to a controller (server side validation), you must check ModelState and if you have an error make sure you pass the model back to your view:
thnks dennis it worked :)
Hi kusum,
Great it works :-).
I think that you should mak the post as solved, so other can see what works for you and jump straight to the solution. Ff you donĀ“t know how to mark a post as solved I will explain it to you.
You have a green tick in the left side of the screen next to the avatar picture. You can mark the question as solved by tick the green tick, for the post that gives you the right answer to your problem. You can only choose one post as the solution.
/Dennis
is working on a reply...