Page 1 of 1

Form Validation

Posted: 31 Jan 2013, 11:43
by Annu
I need to validate text and numeric fields in various forms in different modules. Can any body help how to add validation @simbio classes

Re: Form Validation

Posted: 31 Jan 2013, 17:33
by buitenzorg812
is it possible to change validation through mysql? i mean, field which has to be text set as text and so on.

Re: Form Validation

Posted: 01 Feb 2013, 13:42
by Annu
buitenzorg812 wrote:is it possible to change validation through mysql? i mean, field which has to be text set as text and so on.
Field types in MySQL is already set but I need to validate the form on Submit. How can I do this. I've gone through validate.js that contains some functions regarding isNumber and others field types. How to use them I don't know. So please help me in this regard.

Re: Form Validation

Posted: 18 Feb 2013, 12:55
by Annu
Annu wrote:
buitenzorg812 wrote:is it possible to change validation through mysql? i mean, field which has to be text set as text and so on.
Field types in MySQL is already set but I need to validate the form on Submit. How can I do this. I've gone through validate.js that contains some functions regarding isNumber and others field types. How to use them I don't know. So please help me in this regard.
Done through Code

Re: Form Validation

Posted: 20 Feb 2013, 16:19
by buitenzorg812
Annu wrote:Done through Code
great news then :). if you have time, please share with us here how you manage to handle the problem. at least in later time, someone with similar matter can learn from your point of view. thank you verymuch, annu :).

Re: Form Validation

Posted: 21 Feb 2013, 15:15
by Annu
We can have many validation checks Right After the given code

Code: Select all

    $title = trim(strip_tags($_POST['title']));
+    $edition = trim($dbs->escape_string(strip_tags($_POST['edition'])));

Code: Select all

    // check form validity
    if (empty($title)) {
        utility::jsAlert(__('Title can not be empty'));
        exit();
    }
As I want to check the Edition Field as Numeric so after the above code add the following code and thats it

Code: Select all

if (!is_numeric($edition))
	{
       	utility::jsAlert(__('Please Enter Numeric Value for Edition'));
		$edition.focus();
	    exit();
	}