Sunday, 15 August 2010

Form validation javascript hiding elements -



Form validation javascript hiding elements -

i building form , alerting user can not move next step until input successful

var location=document.getelementbyid("zip").value; if(location==null || location==""){ alert("please insert valid location!"); homecoming false; }

if user continues next step, submit button activated. if user returns step, want hide submit button on step if same input null. how can using javascript? class of submit button 'btfinish'.

thanks!

edit

i using jquery. have tried

$(btprevious).click(function(e) { $(btfinish).hide(); }); $(btnext).click(function(e) { $(btfinish).show(); });

this hides finish button through progression, if there error in input box, , user clicks 'btnext', 'btfinish' show if user must prepare input on first step.

ok understanding here have 2 steps:

1) zip must filled in user clicks go next step. 2) user can either submit finished or go zip code step.

i this:

$(btprevious).click(function(e) { $(btfinish).hide(); }); $(btnext).click(function(e) { $(btfinish).show(); }); $('#zip').keyup(function(){ if ($(this).val() === null || $(this).val() === ""){ $(btfinish).hide(); } else{ $(btfinish).show(); } });

this prevent them clicking on btfinish unless have written in zip. i'm thinking since hve press delete button, should trigger event handler. in event can somehow elsewise clear zip code, check on blur or whatever other event can clear box with.

javascript forms validation hide

No comments:

Post a Comment