Validation for adding atleat three skills in input box using jquery or javascript -
need add validation adding atleast 3 skills in textbox. having form applying job in there option entering primary skills user knows , separated comma.so need add validation if user enters 1 skill while submiting form should show message atleaset 3 skills required. using codeigniter php
<div class="primaryskillss"> <input type="text" class="form-control primaryskills" name="primary_skills" value="<?php echo set_value('primary_skills');?>" placeholder="primary skills(enter 3 skills separated comma)" required> <?php echo form_error('primary_skills', '<div class="error">', '</div>'); ?> </div> <button type="submit" class="btn btn-success successss" id="submits">submit</button>
if(substr_count($_post['primary_skills'],',')<2){ //error }
if forcing user sepperate skills commas, count number of commas there are? it's poor man's way should work...
to prevent users putting ",,", should try fetch using regex test commas separating @ least 1 character:
if(preg_match(/.+,.+,.+/,$_post['primary_skills'])){ //error }
Comments
Post a Comment