Jump to content

[SOLVED] Validating


sirmika

Recommended Posts

Hello all.

 

I am new to php and I hope I am not bothering anyone with simple questions.

 

I have simple field <INPUT TYPE="text" NAME="val1" SIZE="10"> and I want to add validation to it.

I want to allow only numbers and only number that are higher or equal to 500

 

Can anyone help?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/130422-solved-validating/
Share on other sites

are you looking to validate it Client Side (with JavaScript before the form submits) or Server Side (with PHP after the form submits)

 

i'll assume Server Side since you posted in PHP...

 

<?php
  if(empty($_POST['val1']) || !is_numseric($_POST['val1']) || $_POST['val1'] < 500){
    die("Validation Failed");
  }
?>

Link to comment
https://forums.phpfreaks.com/topic/130422-solved-validating/#findComment-676537
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.