Click here to Skip to main content
16,016,345 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Using jquery impromptu popup, i have made a form . But the problem is i want to check the user input before submitting. Is it possible.
In here, if the user selects options in the second screen, i want to call another popup based on it. Is it possible.
JavaScript
var my_states = {
   state0: {
       title: 'Name',
       html:'<label>First <input type="text" name="fname" value=""></label><br />'+
           '<label>Last <input type="text" name="lname" value=""></label><br />',
       buttons: { Next: 1 },
       //focus: "input[name='fname']",
       submit:function(e,v,m,f){
           console.log(f);

           e.preventDefault();
           $.prompt.goToState('state1');
       }
   },
   state1: {
       title: 'Check Here',
       html:'<table><tr><td>Generate Func </td><td>:</td><td id=\'gen_odec\' class=\'gen_odec\'>    <select name=\'select_odec\' id=\'select_odec\' class=\'select_odec\'>'+<?php echo json_encode($odecpref)?>+'</select></td></tr></table>',
       buttons: { Back: -1, Next: 1 },
       //focus: ":input:first",
       submit:function(e,v,m,f){
           console.log(f);

           if(v==1) {$.prompt.close();
                       return false;}
           if(v==-1) $.prompt.goToState('state0');
           e.preventDefault();
       }
   },
    };
    $.prompt(my_states);
Posted
Comments
Pradip R 20-Jan-15 0:42am    
Yes that can be possible. As an approach you can store first state input values in any variables to check whether the textboxes are filled or not. becuase once you go to second state DOM will be cleared for first state and you will no longer find the object of those textboxes.

Once the second state is submitted you can check those first state textbox's variables values to validate and if they are invalid you can go back to state 1 with the help of ipromptu plugin (as you did in your code) so that you can fill the empty textboxes .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900