Need help in validation

Thank you amariussi for taking time and posting code to help.

I have achieved with custom java script function and it needed to tweak:
custom/modules/Leads/Metadata/editvardefs.php with :


 'includes' => 
      array (
        0 => 
        array (
          'file' => 'custom/include/javascript/leadedits.js',
        ),
      ),

Also adding call to custom function in Save button with adding code before width array in same file:


 'form' => 
      array (
        'buttons' => 
        array (
          0 => 
          array (
            'customCode' => '<input title="Save [Alt+S]" accessKey="S" onclick="this.form.action.value=\'Save\'; return check_custom_data();" type="submit" name="button" value="Save">',
          ),
        ),
      ),

And then in javascript file


function check_custom_data()
{
	 var mob1 = document.getElementById('phone_mobile').value.length;
	 var email1 = document.getElementById('Leads0emailAddress0').value.length;
	 if(mob1 == 0 && email1== 0)
	 {
	 alert('Either email or mobile number must be entered to get data saved!');
	 return false;
	}
	else
	{
	return check_form('EditView');	
	}
}

As you seems having implementation of web-to-lead form, i wonder if you can guide what architecture need to be used suppose i have wordpress form and i need data saved directly as lead.

Regards,
Harshad