0
私は(成功:なし)ボタンをクリックする前に、テーブルの "名前" & "description"フィールドへのフォーム検証を試行しています(ライブ検証)。 私が言っていることは、「提出する」ボタンは、すべてが正しい前に何もしません。 (赤色の警告が表示されます空または50よりも高い場合)jquery&CSSを使用しない検証
名前は
説明は、あなたが数を挿入した場合の数字のみ255文字(許可されていません50文字のみ可能となり、空にすることはできませんまたは255を超えるアラートが表示されます)
ここで私のコードは、私はとても頑張ったし、何をすべきか分かりません。ただ、divのIDを設定し、 VAR masgは= 'だけの数' のようにこのコードでmasgを追加
<?php include('connect.php');
$error="";
if(isset($_GET['editar']))
{
$ident=$_GET['iden'];
$row=mysql_query("SELECT * FROM subjects WHERE id=$ident");
$st_row=mysql_fetch_array($row);
}
$sqlm = mysql_query("SELECT * FROM careers");
$options = "";
while($resultado = mysql_fetch_array($sqlm)){
$options .= "<option value='".$resultado['id']."'>".$resultado['nombre']."</option>";
}
?>
<h2 align="center">UPDATE SUBJECTS</h2>
<form method="Post" action=''>
<table align="center">
<tr>
<td>Career:</td>
<td><select name='txtcarreras_id'><?php echo $options; ?></td>
</tr>
<tr>
<td>Name:</td>
<td><input type='text' class="form-text" id="form-name" name='txtnombre' value="<?PHP echo $st_row['nombre'] ?>"/><span class="error-form" id="error-name"></td>
</tr>
<tr>
<td>Description:</td>
<td><input type='text' class="form-text" id="form-description" name='txtdescripcion' value="<?PHP echo $st_row['descripcion'] ?>"/><span class="error-form" id="error-description"></td>
</tr>
<tr>
<td>Hours:</td>
<td>
<select name='txtcarga_horaria'/>
<option <?php if($carga_horaria=='1') echo 'selected' ; ?> value="2">2 (dos)</option>
<option <?php if($carga_horaria=='1') echo 'selected' ; ?> value="4">4 (cuatro)</option>
<option <?php if($carga_horaria=='1') echo 'selected' ; ?> value="6">6 (seis)</option>
<option <?php if($carga_horaria=='1') echo 'selected' ; ?> value="8">8 (ocho)</option>
<option <?php if($carga_horaria=='1') echo 'selected' ; ?> value="10">10 (diez)</option>
</select>
</td>
</tr>
<tr>
<td></td>
<td><input type='submit' value="save" name='btnsave'/></td>
</tr>
</table>
</form>
<?php
if(isset($_POST['btnsave']))
{
$carreras_id=$_POST['txtcarreras_id'];
$nombre=$_POST['txtnombre'];
$descripcion=$_POST['txtdescripcion'];
$carga_horaria=$_POST['txtcarga_horaria'];
$a_sql=mysql_query("UPDATE subjects SET carrera_id='$career_id', name='$nombre', description='$descripcion', hours='$carga_horaria' WHERE id='$ident'");
if($a_sql)
{
header("location:index.php");//
}
}
?>
<script>
function lettersonly(input){
var regex = /[^a-z]/gi;
input.value = input.value.replace(regex, "");
}
</script>
<script>
$(function()){
$("#error-name").hide();
// $("#error-description").hide();
var error_name = false;
// var error_description= false;
$("#form-name").focusout(function() {
check_name();
});
function check_name(){
var nombre_length = $("#form_name").val().length;
if(nombre_length > 50)
{
$("#error-name").html("NO DEBE SUPERAR LOS 50 CARACTERES");
$("#error-name").show();
error_name = true;
}else {
$("#error-name").hide();
}
}
</script>
返事ありがとうございます、私はそれを得ることはありません:/、私は何をすべきですか? –