Forums

how good is CF with Js validation?

michaelc 06 Sep, 2008
hello there- I got a working form and my current validation (coded not mootools) about empty fields works like a charm but when i try to validate a number oor alphanumeric character, somehow CF just assumes everything is right and submits the form. Here part of the code:

function check(form)
{
  if(isNaN(form.postcode.value))
  {
    alert("Error');
    return false;
  }

return true;
}


Can we use this type of code in CF???? or only this types works?:

if(form.lastName.value == "")  {
   alert etc etc

Thanks in advance
Max_admin 07 Sep, 2008
Hi Michael,

any type of JS should work as long as it works anywhere else, whats the value of form ??
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
michaelc 07 Sep, 2008
Well this is the thing. the code works elsewhere but will not work under CF. What CF does assumes everything is ok and moves on... hmmm form name = form.
Do u know if someone was able to make the "if(isNaN(form.postcode.value))" work??? Thanks
Max_admin 07 Sep, 2008
Hi,

I need to see the form= line in your js code, Chronoforms adds ChronoContact_ extension before the form name, so if you gave your form the name of "myform" in the form management then at the actual code it will be ChronoContact_myform!

Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
michaelc 08 Sep, 2008
Sorry man but i don't get you-- the form name is 'form'...
the first bit of code I posted works but when i have to check for numbers or alphanumeric they dnt work... let me repaste something--

  function checkForm(form)
{
if(form.firstName.value == "")  {
   alert("Please enter your First Name");
   return false;
  }
return true;
}



This works like a charm but if you include this code it checks the firstname and then skips the postcode bit and submits the form..

  function checkForm(form)
{
if(form.firstName.value == "")  {
   alert("Please enter your First Name");
   return false;
  }
if(isNaN(form.postcode.value))
  {
    alert("Please enter...");
    return false;
  }

return true;
}

I'm badly stuck- Thanks in advance
Max_admin 08 Sep, 2008
Hi,

well, how do you trigger the check function ? onsubmit event ? using the "this" ?
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
michaelc 09 Sep, 2008
hello i'm using this line in the General tab of CF:
onSubmit="return checkForm(this)"
Max_admin 09 Sep, 2008
Good, then it should work and I have just worked on a form which uses the same code idea and using isNaN function also, I can test your code if you like ?
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
This topic is locked and no more replies can be posted.