AbdulBazith's avatar

My hidden input fields also validated in javascript how to solve

Guys iam working with a project.

iam using native-validations-master downloaded it from net.

to perform validation i need to attach the form-validation.js file in my project and then,

in my form


document.getElementById('experience_form').validateForm();

//where experience_form is my form name and validateForm is function name in the validation js file

my problem is i have hidden input fields in this form. those also validated so that i cant subit the form.

if that input fields are visible then only it must be validated. how to do that?

i searched in net and did this


  document.getElementById('experience_form').validateForm(
        {
         ignore: "#hidden"
         }
  );


but not worked.

i referred in net but most of the solutions are based on jquery

what can i do

Kindly some one help please..

0 likes
7 replies
michaelcharles's avatar

Instead of ignoring your hidden inputs, I think it is better if you do validate them. Remember: A hidden input can still be accessed by any user who knows how to use Chrome dev tools. A malicious user or script could still easily pass unwanted data that way.

AbdulBazith's avatar

@michaelcharles thank you for your suggestion..

you are right.

but some times i need to hide the textbox and it should not be validated.

what should i do??

realrandyallen's avatar
Level 44

@ABDULBAZITH - Can you link to the validation package you're using? Also, you could probably just use a different validation package if this one isn't doing everything you need it to...of course that could be easier said than done if the current one is used throughout a large project

AbdulBazith's avatar

@realrandyallen i have posted this as a new post because i found almost solution, still facing problem. in that new post i explained everthing with images and coidng. Kindly if possible help me please.

Link: https://laracasts.com/discuss/channels/javascript/disable-required-input-property-is-not-working-and-still-validating

Question: disable required input property is not working and still validating.

And thank you so much for your resposes

Bernard-Oreva's avatar

Your problem might be the way you hide your controls you want to avoid validations on.

This will not work. It will still get validated.

$("input[name='someInput']").css("visibility", "hidden");

Hide your controls this way to prevent validations:

$("input[name='someInput']").css("display", "none");

Please or to participate in this conversation.