tags:

views:

55

answers:

6
+2  Q: 

html form class

Is there any html form class(text box) that does not allow null values. The inputted data is to be stored in a mysql database.

+3  A: 

No.

Use Javascript to check on client side if every text box is filled, and also sanitize the input on the server.

KennyTM
+1 It's important to remark, as KennyTM did, that you need to sanitize on *both* the front- and back-end. Javascript may fail, and can be overridden.
D_N
+2  A: 

There is not such input as of i know, you should perform the validation server-side instead to check if the value is null or rather empty. You could also use javascript for that:

if (document.getElementById("input_id").value != "")
{
  // it is not empty, proceed.......
}

Form Validation Using JavaScript.

Sarfraz
would this value(input_id) be the declared, and should be the same as the name of the textbox?--><input name="input_id" type="text" id="input_id" maxlength="4">
you just give your text box an id like id="user225269". see my modified answer on how to validate form using javascript. Hope that helps, bye
Sarfraz
+1  A: 

You can do this via JavaScript. Look for JavaScript validation (e.g. JQuery.validation). Oherwise you will have to parse the result and ensure that the value meets your requirements prior to saving it to the db.

Obalix
+2  A: 

you can using Javascript to check if text empty this function will help you just passing in form(onsubmit="return FormValidation();) i hope this code help you

function FormValidation()
    {
        if(orderform.fullname.value == "")
        {
            alert("Please enter your fullname");
            orderform.fullname.focus();
            return false;
        }
        if(orderform.email.value == "")
        {
            alert("Please enter your email");
            orderform.email.focus();
            return false;
        }
        if(orderform.telephone.value == "")
        {
            alert("Please enter your telephone");
            orderform.telephone.focus();
            return false;
        }
        if(forgetform.txtusername.value == "Username")
        {
            alert("Please enter your Username");
            orderform.txtusername.focus();
            return false;
        }
    }
Mahran Elneel
thanks, this will do for a beginner like me
A: 

Yes, use a regular text box:

<input type="text" name="Name" />

This will always return a value, there is no way to enter a null value into it.

Of course you need to validate the data on the server side, the form can be spoofed so there is no client side method of ensuring that the data sent to the server is valid.

Guffa
+1  A: 

No, you can use javascript on client side and/or php on server side to check that the values are filled in correctly

If you use a js framework like mootools you can give a look at this http://mootools.floor.ch/en/demos/formcheck/

ghedamat