Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2573
  • Last Modified:

Live Validation

Hello,

I am currently attempting to work with live validation (http://www.livevalidation.com/)
It works great in firefox for me, However i seem to have run into some problems in IE.

If i leave my form empty or input incorrect input i get an error was would be expected.

However When i submit a valid form i end up getting a page reload, If the input is valid ajax.request calls are initiated.  

The problem is that in order to use the live validation library on form submit the input type must be "submit" and to stop the page from reloading in IE7 the input type is "button"

So i am at a cross roads as to how i can make this work correctly for me.

Any help would be appreciated.
//input Form
<form  action="#" method="post">
								<label for="ip">IP:</label>
								<input type="text" name="ip" id="ip"/>
								<br/>
								<label for="ip">Case:</label>
							<input type="text" name="ticket" id="ticket"/> 
								<br/>
								<input type="submit" value="Submit" name="submit" onclick="checkInput()"/>
							
						</form>
 
/// JS function
function checkInput()
	{
	var ip = new LiveValidation('ip', {onlyOnSubmit: true } );
  ip.add( Validate.Presence );
  ip.add( Validate.Custom, { against: function(value){ return isValidIPAddress(value) }, failureMessage: "IP is not valid" } ); 
    var ticket = new LiveValidation('ticket', {onlyOnSubmit: true } );
	ticket.add( Validate.Presence );
  ticket.add( Validate.Custom, { against: function(value){ return Case(value) }, failureMessage: "Case is not valid" } ); 
 
          var ipSubmit = ip.form.onsubmit;
		  var ticketSubmit = ticket.form.onsubmit;
          ip.form.onsubmit = function(){
	          var validIP = ipSubmit();
			  var validCase = ticketSubmit();
	          if((validIP)& (validCase))
			  getActionBack('0');
            return false;
			
		  }
	
	}

Open in new window

0
Defunct-Exodus
Asked:
Defunct-Exodus
  • 4
  • 2
1 Solution
 
Michel PlungjanIT ExpertCommented:
1. do NOT name anything submit
2. do NOT execute stuff in the onClick of a submit
3. does livevalidation accept this:

<form  action="#" method="post" onSubmit="checkInput(); return false">

<input type="submit" value="Submit" />
</form>


0
 
Michel PlungjanIT ExpertCommented:
Ahh, you already return false...

So why do you do all this stuff onClick???

try this:

window.onload=function() {
  var ip = new LiveValidation('ip', {onlyOnSubmit: true } );
  ip.add( Validate.Presence );
  ip.add( Validate.Custom, { against: function(value){ return isValidIPAddress(value) }, failureMessage: "IP is not valid" } ); 
  var ticket = new LiveValidation('ticket', {onlyOnSubmit: true } );
  ticket.add( Validate.Presence );
  ticket.add( Validate.Custom, { against: function(value){ return Case(value) }, failureMessage: "Case is not valid" } ); 
  var ipSubmit = ip.form.onsubmit;
  var ticketSubmit = ticket.form.onsubmit;
  ip.form.onsubmit = function(){
    var validIP = ipSubmit();
    var validCase = ticketSubmit();
    if((validIP)& (validCase)) getActionBack('0');
    return false;
  }
}
 
and ignore my previous post

Open in new window

0
 
Defunct-ExodusAuthor Commented:
mplungjan,

Thank you for your responses, I had actually already removed that oneclick and also moved the contents of the functions into dom:loaded

I have replaced my code with yours, It works in FIreFox, But in IE7 it still submits the page if all values pass the live validation restraints.

Instead of just using ajax.request like it does in firefox.

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Michel PlungjanIT ExpertCommented:
Depends on what you do in ipSubmit and tichetSubmit

If you submit anyway or you have an error, IE will return true and let the form submit anyway = reload in your case
0
 
Defunct-ExodusAuthor Commented:
Hm okay that makes sense.

But there are no errors, And after the validation is passed it should just be calling in agajx.request function instead of going to action="#"
0
 
Michel PlungjanIT ExpertCommented:
I would need to see the whole html/script somwhere
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now