I have used the below code for form submission and validation, but form is not getting submitted when it gets validated.
<form action = "/edit/{{$users[0]->id}}" id="myform" method = "post">
<input type = "hidden" name = "_token" value = "{{csrf_token()}}">
<div class="form-group">
<label for="Name">Name</label>
<input id="my-input" name="name" class="form-control left" value="{{$users[0]->name}}" type="text">
</div>
<div class="form-group">
<label for="url">Name of the Link</label>
<input type="text" name="url" id="url" class="form-control" value = "{{$users[0]->url}}" aria-describedby="helpId">
</div>
<div class="form-group">
<label for="Category">Category</label>
<select name="category" class="form-control">
<option value="<?php echo $users[0]->category; ?>" selected><?php echo $users[0]->category; ?></option>
<option value="Human Resource">Human Resource</option>
<option value="Decksys">Decksys</option>
<option value="Pentaho">Pentaho</option>
<option value="Makto">Makto</option>
<option value="Carton">Carton</option>
</select>
</div>
<input type="submit" class="btn btn-primary" value="Submit">
</form>
Find below the script which I have used :
<script type="text/javascript">
// just for the demos, avoids form submit
jQuery.validator.setDefaults({
debug: true,
success: "valid"
});
$( "#myform" ).validate({
rules: {
url: {
required: true,
url: true
}
}
});
</script>
Find the controller code below
public function edit(Request $request,$id) {
$name = $request->input('name');
$url = $request->input('url');
$category = $request->input('category');
DB::update('update links set name = ?,url=?,category=? where id = ?',[$name,$url,$category,$id]);
\Session::flash('message', 'Successfully updated!');
return redirect()->route('home');
}
Kindly suggest a solution to submit the form along with form validation.
parsley. Which is better solution of client side validation