bootstrap input name属性一样 验证问题解决办法是什么?

bootstrap input name属性一样怎么验证,在线等。

2个回答

比如这两个input框


name属性是一样的,可以加id或者data来区分其值,jquery方式用id取第一个框的值$("#id1").val();
也可以用data来区分,比如取第一个input的data的值,当然这里也要用到id,$('#id1').attr("data");

dongbeiou
小鱼儿511 回复linkliu1994: jqeury validate验证name属性相同的解决办法。
3 年多之前 回复
linkliu1994
linkliu1994 忘了贴代码片了,input代码在二楼,然后attr中的值可以自己定义的,$("#id1").val()得到(1框)这两个字,$('#id1').attr("data")得到的是(data1)几个字符
3 年多之前 回复
<input type='text' id="id1" name='ids' value="1框" data="data1"/>
<input type='text' id="id2" name='ids' value="2框" data="data1"/>
dongbeiou
小鱼儿511 jqeury validate 相同name值的解决办法,验证
3 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
bootstrapValidator验证的input属性名有点,怎么办?

``` <input id="serviceNumber" name="cdnOrder.serviceNumber" placeholder="服务单号" type="text" class="form-control" /> ``` ``` $('#addDialog').bootstrapValidator({ message: '验证未通过!', feedbackIcons: { valid: 'glyphicon glyphicon-ok', invalid: 'glyphicon glyphicon-remove', validating: 'glyphicon glyphicon-refresh' }, fields: { cdnOrder.serviceNumber: { validators: { notEmpty: { message: '不能为空!' } } } } }); ``` bootstrapValidator不支持类名点属性名的字段验证,怎么解决?

使用Bootstrap验证来验证表单字段

<div class="post-text" itemprop="text"> <p>I hope you all can give me a push in the right direction. I am creating a form using html/css &amp; bootstrap. The form works kind of but I would like to use the validation states bootstrap offers. How do I use this in the right way? A field only should go green when it's correctly filled and red when an error occurs. </p> <p>Can anyone give me an example on how I can show the correct state? (so green when correctly filled, red when not)</p> <pre><code>&lt;div class="container"&gt; &lt;form method="post" action="&lt;?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?&gt;"&gt; &lt;div class="row"&gt; &lt;div class="col-xs-3" style="padding-right:5px;"&gt; &lt;label for="ex1" &gt;&lt;/label&gt; &lt;input class="form-control inputForm" id="ex1" name="voornaam" type="text" placeholder="Voornaam"&gt; &lt;/div&gt; &lt;div class="col-xs-3" style="padding-left:5px;"&gt; &lt;label for="ex2"&gt;&lt;/label&gt; &lt;input class="form-control inputForm" id="ex2" type="text" name="achternaam" placeholder="Achternaam"&gt; &lt;/div&gt; &lt;/div&gt;&lt;div class="row"&gt; &lt;div class="col-xs-6"&gt; &lt;label for="ex3"&gt;&lt;/label&gt; &lt;input class="form-control inputForm" id="ex3" name="email" type="text" placeholder="Voer je e-mailadres in"&gt; &lt;/div&gt;&lt;/div&gt; &lt;div class="row"&gt; &lt;div class="col-xs-6"&gt; &lt;label for="ex3"&gt;&lt;/label&gt; &lt;input class="form-control inputForm" id="ex3" name="wachtwoord" type="password" placeholder="Wachtwoord"&gt; &lt;/div&gt;&lt;/div&gt; &lt;div class="row"&gt; &lt;div class="col-xs-6"&gt; &lt;input class="btn btn-primary btn-lg active" type="submit" value="Registeren" style="Float: right; margin-top: 15px; width: 100%;"&gt; &lt;/div&gt;&lt;/div&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> </div>

如何在Bootstrap模式中添加表单验证错误

<div class="post-text" itemprop="text"> <p>I want to display form validation error in the Bootstrap modal (below the input fields), I have done it previously, but now since I am using ajax to send the data I am having trouble displaying the validation error.</p> <p>Please Help. Thanks in advance</p> <pre><code>**View** &lt;div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true"&gt; &lt;div class="modal-dialog modal-dialog-centered" role="document"&gt; &lt;div class="modal-content"&gt; &lt;form id="myform"&gt; &lt;div class="modal-body"&gt; &lt;?php echo validation_errors(); ?&gt; &lt;input class="form-control" type="text" name="user_name" id="user_name"&gt; &lt;input class="form-control" type="text" name="name" id="name"&gt; &lt;/div&gt; &lt;div class="modal-footer"&gt; &lt;button type="button" class="btn btn-secondary" data-dismiss="modal"&gt;Close&lt;/button&gt; &lt;button type="submit" class="btn btn-primary" id="add"&gt;Save changes&lt;/button&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;script&gt; $(document).ready(function () { $(document).on('submit','#myform',function(event){ event.preventDefault(); let name=$("#name").val(); let user_name=$("#user_name").val(); $.ajax({ url:"&lt;?php echo base_url(). 'welcome/add_data';?&gt;", method: 'POST', data:new FormData(this), contentType:false, processData:false, success:function (data) { alert(data); $('#myform')[0].reset(); $('#myModal').modal('hide'); location.reload(); } }); }) }) &lt;/script&gt; **Controller** public function add_data(){ $this-&gt;form_validation-&gt;set_rules('name', 'Name', 'required'); $this-&gt;form_validation-&gt;set_rules('user_name', 'User Name', 'required'); if ($this-&gt;form_validation-&gt;run() == FALSE) { $this-&gt;load-&gt;view('main_view'); } else { $data=array( 'name'=&gt;$this-&gt;input-&gt;post('name'), 'user_name'=&gt;$this-&gt;input-&gt;post('user_name'), ); $this-&gt;Test_model-&gt;add_data($data); redirect('welcome',"refresh"); } } </code></pre> </div>

Bootstrap 3 JQuery验证不起作用

<div class="post-text" itemprop="text"> <p>I am working on Symfony2 project and have used bootstrap 3.0.2. I have used jquery validation 1.9.0 plugin for login validation. I want to do somethi like this<a href="http://jsfiddle.net/hTPY7/527/" rel="nofollow noreferrer">Fiddle</a> is worked in core php but in symfony it doesn't work. Here is my code</p> <p><strong>Login.html.twig</strong></p> <pre><code>&lt;script src="{{asset('bundles/Loginbundle/js/script.js')}}"&gt;&lt;/script&gt; &lt;script src="{{asset('bundles/Loginbundle/js/jquery-1.7.1.min.js')}}"&gt;&lt;/script&gt; &lt;script src="{{asset('bundles/Loginbundle/js/jquery.validate.min.js')}}"&gt;&lt;/script&gt; &lt;link href="{{asset('bundles/Loginbundle/css/bootstrap.css')}}" rel="stylesheet"&gt; &lt;form id="contact-form" class="form-horizontal" action="{{ path('login_login_homepage')}}" method="POST"&gt; &lt;div class="form-group"&gt; &lt;label class="control-label" for="user"&gt;Username:&lt;/label&gt; &lt;div class="input-group"&gt; &lt;span class="input-group-addon"&gt;@&lt;/span&gt; &lt;input type="text" class="form-control" name='user' placeholder='Username' /&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label class="control-label" for="pass"&gt;Password:&lt;/label&gt; &lt;div class="input-group"&gt; &lt;span class="input-group-addon"&gt;&lt;/span&gt; &lt;input class="form-control" type='password' name='pass' placeholder='Password'/&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="checkbox"&gt; &lt;label&gt; &lt;input type="checkbox" name="remember"&gt; Remember Me &lt;/label&gt; &lt;/div&gt; &lt;!--&lt;input type="checkbox" name="remember" value="Remember-Me"&gt;&lt;p style="display:inline;"&gt; &amp;nbsp;Remember Me&lt;/p&gt; --&gt; &lt;button class="btn btn-primary" type="submit" &gt;SignIn&lt;/button&gt; &lt;a href="{{path('login_login_signup')}}"&gt;Sign Up&lt;/a&gt; &lt;br&gt;&lt;br&gt;&lt;br&gt; &lt;/form&gt; </code></pre> <p><strong>scripy.js</strong></p> <pre><code>$('form').validate({ rules: { user: { minlength: 5, maxlength: 15, required: true }, email: { required: true }, pass: { minlength: 5, maxlength: 15, required: true } }, highlight: function(element) { $(element).closest('.form-group').addClass('has-error'); $(element).closest('.form-group').removeClass('has-success'); }, unhighlight: function(element) { $(element).closest('.form-group').removeClass('has-error'); $(element).closest('.form-group').addClass('has-success'); }, errorElement: 'span', errorClass: 'help-block', errorPlacement: function(error, element) { if (element.parent('.input-group').length) { error.insertAfter(element.parent()); } else { error.insertAfter(element); } } }); </code></pre> <p>I have tried to debig using firebug and it shows error as below</p> <p><img src="https://i.stack.imgur.com/kYXhs.jpg" alt="enter image description here"> But, still not working.Please help me out.</p> </div>

仅当字段包含值时,Bootstrap才会进行验证

<div class="post-text" itemprop="text"> <p>Bootstrap validate only if field contain value</p> <p>I would like to only use my bootstrap validator if</p> <p>I got this code below that use bootstrap validator</p> <pre><code>&lt;tr&gt; &lt;td&gt;&lt;b&gt;1&lt;/b&gt;&lt;/td&gt; &lt;td&gt; &lt;select class="form-control" name="DaySelection1"&gt; &lt;option value=""&gt;Select&lt;/option&gt; &lt;option value="wed"&gt;Wed&lt;/option&gt; &lt;option value="thu"&gt;Thu&lt;/option&gt; &lt;option value="fri"&gt;Friday&lt;/option&gt; &lt;/select&gt; &lt;/td&gt; &lt;td class="form-group"&gt; &lt;input type="text" class="form-control" name="digits1" required min="000" data-bv-greaterthan-inclusive="true" data-bv-greaterthan-message="The input must be greater than or equal to 0" max="999" data-bv-lessthan-inclusive="false" data-bv-lessthan-message="The input must be less than or equal to 999" /&gt; &lt;/td&gt; &lt;td class="form-group"&gt;&lt;input type="number" data-bv-digits-message="true" class="form-control" name="big1" id="name1" size="6"&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="number" class="form-control" name="small1" size="6"&gt;&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>I would only like to run my validate on the row that the</p> <pre><code>select class by the name "DaySelection" value is not "" </code></pre> <p><code>The name of each input is goes by e.g "digits$i", "big$i", "small$i"</code> </p> <p>where $i is a integer of </p> <pre><code>1 to 10 </code></pre> <p>to identify each individual row of input type</p> <p>How do I change my bootstrap code.</p> <p>Because currently I got a for loop that print out the same field, those field that are not filled up also got this validation done, I only want to validate row that got DaySelection value</p> </div>

Bootstrap Modal中的JQuery验证表单在验证后不会提交

<div class="post-text" itemprop="text"> <p><strong>UPDATE:</strong> To put the question into perspective I created another <a href="https://jsfiddle.net/h6onufs5/12/" rel="nofollow noreferrer">Fiddle</a> that shows the same form outside of the modal. </p> <p>When it meet the right conditions i.e you type an email address and hit the Get Started button it submits properly display the PHP page, in this case it shows a 404 error, but it does what is supposed to do, <strong>SUBMIT!</strong> </p> <p><strong>ORIGINAL PROBLEM:</strong> Now back to the problem: I would like to submit my form inside a bootstrap modal, but when I open the modal and type an email, and press the get started button: <strong>NOTHING HAPPENS</strong> </p> <p><a href="https://i.stack.imgur.com/GxfF3.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GxfF3.jpg" alt="php won't submit"></a></p> <p><strong>What am I doing wrong? Is there a JavaScript solution missing to submit the form correctly or are the validation errors interfering?</strong> </p> <p>I'm a novice in JavaScript so I can't seem to figure out the coding solution if it's in fact js based. </p> <p>Please help me figure this strange modal issue, thank you!</p> <p>Fiddle: <a href="https://jsfiddle.net/o5vpt6ck/3/" rel="nofollow noreferrer">https://jsfiddle.net/o5vpt6ck/3/</a></p> <p><strong>HTML:</strong></p> <pre><code>&lt;form id="signup-form" class="cd-signin-modal__form" action="confirm.php" method="post"&gt; &lt;h3 class="bigsentence black text-center font-weight-bold"&gt;Create&lt;/h3&gt; &lt;p class="cd-signin-modal__fieldset"&gt; &lt;label class="cd-signin-modal__label cd-signin-modal__label--email cd-signin-modal__label--image-replace" for="signup-email"&gt;Enter your email address&lt;/label&gt; &lt;input class="cd-signin-modal__input cd-signin-modal__input--full-width cd-signin-modal__input--has-padding cd-signin-modal__input--has-border signupfield" id="email" type="email" name="email" placeholder="Enter your email address"&gt; &lt;/p&gt; &lt;p class="cd-signin-modal__fieldset"&gt; &lt;input class="cd-signin-modal__input cd-signin-modal__input--full-width" name="submit" type="submit" value="GET STARTED"&gt; &lt;/p&gt; &lt;/form&gt; </code></pre> <p>JS:</p> <pre><code>$("#signup-form").validate ({ // validation rules for registration formd errorClass: "error-class", validClass: "valid-class", errorElement: 'div', errorPlacement: function(error, element) { if(element.parent('.input-group').length) { error.insertAfter(element.parent()); } else { error.insertAfter(element); } }, onError : function(){ $('.input-group.error-class').find('.help-block.form-error').each(function() { $(this).closest('.form-group').addClass('error-class').append($(this)); }); }, rules: { email: {email:true, required:true} }, messages: { email: { required: "Please enter your email address", }, highlight: function(element, errorClass) { $(element).removeClass(errorClass); } } }); </code></pre> </div>

使用bootstrap验证程序检查重复的mysql数据

<div class="post-text" itemprop="text"> <p>I created a signup form with the bootstrap validator and connected it to a MySQL database. I wish to prevent duplicate entries by checking for existing email data and returning a message through the bootstrap validator script. I am using the remote method but the problem is as soon as I start typing in the email field, I get the "Email has already been taken." message although the email may not already exist in the database or if it is only one alphabet typed. I also get data entries even when I have not submitted the form. I have searched online and realized most of the solutions exist for the jquery validation plugin but no the bootstrap validator. I need help, please. Here is my code:</p> <p><strong>signup.php</strong></p> <p> </p> <pre><code> &lt;div class="signup-form"&gt; &lt;h1&gt;Sign up for free!&lt;/h1&gt;&lt;br&gt; &lt;form id="form1" action="registration.php" class="loading-form" method="POST"&gt; &lt;div class="form-group"&gt; &lt;label for="name-input"&gt;Username&lt;/label&gt; &lt;input required type="text" name="username" class="form-control" id="username" maxlength="100"&gt; &lt;/div&gt; &lt;label for="email-input"&gt;Email&lt;/label&gt; &lt;input required name="email" type="email" class="form-control" id="email" title="An email is required"&gt; &lt;/div&gt; &lt;p&gt;You accept our &lt;a href="pages/terms.php" style="color: #337ab7;"&gt;Terms &amp;amp; Conditions&lt;/a&gt; by creating your account.&lt;/p&gt; &lt;div class="form-group"&gt; &lt;!-- Do NOT use name="submit" or id="submit" for the Submit button --&gt; &lt;button type="submit" class="btn btn-success"&gt;Sign up&lt;/button&gt; &lt;/div&gt; </code></pre> <p> </p> <pre><code> &lt;script&gt; $(document).ready(function() { $('#form1').bootstrapValidator({ // To use feedback icons, ensure that you use Bootstrap v3.1.0 or later feedbackIcons: { valid: 'glyphicon glyphicon-ok', invalid: 'glyphicon glyphicon-remove', validating: 'glyphicon glyphicon-refresh' }, fields: { username: { message: 'The username is not valid', validators: { notEmpty: { message: 'The username is required' }, stringLength: { min: 6, max: 30, message: 'The username must be more than 6 and less than 30 characters long' }, regexp: { regexp: /^[a-zA-Z-' ]+$/, message: 'The username can only consist of alphabetical and number' }, different: { field: 'password', message: 'The username and password cannot be the same as each other' } } }, email: { validators: { notEmpty: { message: 'The email address is required' }, emailAddress: { message: 'The email address is not a valid' }, remote: { message: 'The email address is already taken.', url: "registration.php" } } }, } }); }); </code></pre> <p></p> <p></p> <p></p> <p><strong>registration.php</strong></p> <pre><code>&lt;?php include ("connect.php"); session_start(); $username = $_POST['username']; $email = $_POST['email']; $username = mysqli_real_escape_string($con, $_POST['username']); $email = mysqli_real_escape_string($con, $_POST['email']); $query1 = "SELECT * FROM registration where (email='$email')"; $check = mysqli_query($con, $query1); $checkrows=mysqli_num_rows($check); if($checkrows&gt;0) { echo json_encode(FALSE); } else { echo json_encode(TRUE); } //insert results from the form input $query = "INSERT INTO registration (username, email) VALUES('$username', '$email')"; $result = mysqli_query($con, $query); $num1=mysqli_num_rows($result); $row = mysqli_fetch_assoc($result); ?&gt; </code></pre> </div>

使用bootstrap nav-pill单击“下一步”按钮进行表单验证

<div class="post-text" itemprop="text"> <p>I am using <code>nav-pill</code> inside which there is a form and that is split up into each part say as admission details, personal details, family Details with "Next" button on each step and save button at last <code>nav-pill</code>.</p> <p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>$('.btnNext').click(function() { $('.nav-pills &gt; .active').next('li').find('a').trigger('click'); }); $('.btnPrevious').click(function() { $('.nav-pills &gt; .active').prev('li').find('a').trigger('click'); }); // Bind the event handler to the "submit" JavaScript event $('#validateFirst').click(function() { // Get the Login Name value and trim it var name = $.trim($('#admission_no').val()); // Check if empty or not if (name === '') { alert('Admission No. field is empty.'); return false; } });</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt; &lt;link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" /&gt; &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"&gt;&lt;/script&gt; &lt;ul class="nav nav-pills nav_content"&gt; &lt;li class="active"&gt;&lt;a data-toggle="pill" href="#admission"&gt;Admission Details&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a data-toggle="pill" href="#personal"&gt;Personal Details&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a data-toggle="pill" href="#family"&gt;Family Details&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;form id="form1" action="&lt;?php echo site_url('student/create') ?&gt;" id="employeeform" name="employeeform" method="post" accept-charset="utf-8" enctype="multipart/form-data"&gt; &lt;div class="tab-content"&gt; &lt;div id="admission" class="tab-pane fade in active"&gt; &lt;div class="row"&gt; &lt;div class="col-md-3"&gt; &lt;div class="form-group"&gt; &lt;label for="exampleInputEmail1"&gt;Admission Number *&lt;/label&gt; &lt;input id="admission_no" name="admission_no" placeholder="" type="text" class="form-control" value="admission_no" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="col-md-3"&gt; &lt;div class="form-group"&gt; &lt;label for="exampleInputEmail1"&gt;Application Number *&lt;/label&gt; &lt;input id="application_no" name="application_no" placeholder="" type="text" class="form-control" value="application_no" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="col-md-3"&gt; &lt;div class="form-group"&gt; &lt;label for="exampleInputEmail1"&gt;Academic Year *&lt;/label&gt; &lt;input id="academic_year" name="academic_year" placeholder="" type="text" class="form-control" value="academic_year" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;a class="btn btn-primary btnNext pull-right" id="validateFirst"&gt;Next&lt;/a&gt; &lt;/div&gt; &lt;div id="personal" class="tab-pane fade"&gt; &lt;div class="row"&gt; &lt;div class="col-md-3"&gt; &lt;div class="form-group"&gt; &lt;label for="exampleInputEmail1"&gt;First Name *&lt;/label&gt; &lt;input id="firstname" name="firstname" placeholder="" type="text" class="form-control" value="firstname" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="col-md-3"&gt; &lt;div class="form-group"&gt; &lt;label for="exampleInputEmail1"&gt;DOB *&lt;/label&gt; &lt;input id="dob" name="dob" placeholder="" type="text" class="form-control" value="DOB" readonly="readonly" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="col-md-3"&gt; &lt;div class="form-group"&gt; &lt;label for="exampleInputFile"&gt;Address *&lt;/label&gt; &lt;textarea id="student_address" name="student_address" placeholder="" class="form-control" rows="2"&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;a class="btn btn-primary btnPrevious pull-left"&gt;Previous&lt;/a&gt; &lt;a class="btn btn-primary btnNext pull-right"&gt;Next&lt;/a&gt; &lt;/div&gt; &lt;div id="family" class="tab-pane fade"&gt; &lt;div class="row"&gt; &lt;div class="col-md-3"&gt; &lt;div class="form-group"&gt; &lt;label for="exampleInputEmail1"&gt;Father Name *&lt;/label&gt; &lt;input id="father_name" name="father_name" placeholder="" type="text" class="form-control" value="father_name" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="col-md-3"&gt; &lt;div class="form-group"&gt; &lt;label for="exampleInputEmail1"&gt;Father Occupation *&lt;/label&gt; &lt;input id="father_occupation" name="father_occupation" placeholder="" type="text" class="form-control" value="father_occupation" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="col-md-3"&gt; &lt;div class="form-group"&gt; &lt;label for="exampleInputEmail1"&gt;Mother Name *&lt;/label&gt; &lt;input id="mother_name" name="mother_name" placeholder="" type="text" class="form-control" value="mother_name" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;a class="btn btn-primary btnPrevious pull-left"&gt;Previous&lt;/a&gt; &lt;button type="submit" class="btn btn-info pull-right"&gt;Save&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt;</code></pre> </div> </div> <p>I have tried with button click function while clicking "Next" button like:</p> <pre><code>$('#validateFirst').click(function () { // Get the Login Name value and trim it var name = $.trim($('#admission_no').val()); // Check if empty of not if (name === '') { alert('Text-field is empty.'); return false; } }); </code></pre> <p>Where button has <code>id</code> "validateFirst",</p> <pre><code>&lt;a class="btn btn-primary btnNext pull-right" id="validateFirst"&gt;Next&lt;/a&gt; </code></pre> <p>Here it shows <code>alert</code> when the admission no input is not filled but moves to the next tab (<em>i.e.</em>) personal details while clicking the next button. The thing i am in the need is while clicking the next button if the fields in the current <code>nav-pill</code> fields are empty (say admission no field is not filled in first nav pill) and clicking the next button, it should display alert and should not move to next <code>nav-pill</code> to rectify the invalid input fields in the current nav-pill.. I had a look around other questions but I couldn't get a clear solution. Kindly help me with a solution to resolve this issue.</p> </div>

JavaScript验证 - document.getElementById在Bootstrap模式中不起作用

<div class="post-text" itemprop="text"> <p>I am using an <code>onSubmit()</code> function to validate form entries.</p> <p>The form and validation function work OK,if the form is in a standalone php file or an html file.</p> <p>But when the form is embedded in a Bootstrap modal the JS validation function throws an error message. <code>[object HTMLInputElement]</code></p> <p>I have tried changing <code>document.getElementById('uemail')</code> to <code>document.getElementById('uemail').value</code> as recommended in another answer, but no value has apparently been passed to the function.</p> <p>If I remove the <code>onSubmit()</code> attribute then the values are passed correctly to the action script on the server.</p> <p>This must be common usage. What am I doing wrong?</p> <p>This is an abbreviated section of my code:</p> <pre><code>&lt;script&gt; function formCheck() { var valid = true; //alert('in function'); var email = document.getElementById('uemail'); alert('email:' + email); var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if (!filter.test(email)) { alert('Please provide a valid email address'); email.focus; valid = false; } return valid; } &lt;/script&gt; &lt;form id="regform" action="action.php" method="post" onSubmit="return formCheck()"&gt; Email: &lt;input type="text" name="uemail" id="uemail" size="50" value="" required&gt;&lt;span id ="ast"&gt;*&lt;/span&gt;&lt;br&gt; &lt;input type="submit" name="Submit" value="Register" /&gt; &lt;/form&gt; </code></pre> </div>

vue 自定义组件怎么去动态绑定多个input的model

<template> <div> <div> <label for='input-one'> name: <input id='input-one' v-bind:value='domianData.name' v-on:input="$emit('input', {name: $event.target.value, age: value.age})"></input> </label> <label for='input-two' v-for="item in data1" :key="item.key"> age: <input id='item.key' :value='domianData.age' v-on:input="$emit( 'input', {name: value.name, age: $event.target.value}) "></input> </label> </div>` </div> </template> <script> export default { props: ['value'], data () { return { data1: [ { key: '1111111111', value: '萨达' }, { key: '2222222222', value: '阿斯达' } ], domianData: this.value } }, methods: { clickInput (val) { }, onChange () { this.domianData = '我是由子组件触发改变了内容' } }, watch: { value (val) { console.log(val); this.domianData = val }, domianData (val) { console.log(val); this.$emit('input', val) } }, } </script> <style scoped> </style>

jquery的append动态添加输入框后class无效的问题?

用jquery的append方法table动态添加一行,有一个输入框,用了easyui的class做验证,但是不起作用,用属性获取的方式class和precision的值都是有的,但是无法起到验证的效果,有什么解决办法? 代码: <input class="easyui-numberbox" precision="2" type="text"></input>

验证后如何保持Bootstrap PopUp表单?

<div class="post-text" itemprop="text"> <p>I'm actually developing a Web site where you can register yourself from a form.</p> <p>I've create a code in <em>PHP</em> for managing the errors which could happen (wrong number, mail...)</p> <p>Here is my problem : When I send the form, I cant manage to stay on it to overwrite the form with the errors encounters (if there are some).</p> <p>I'm using Bootstrap form the form and I have absolutely no clue of how to do that.</p> <h2>This is the my <strong>HTML</strong></h2> <pre><code> &lt;div class="modal fade" id="ins" role="dialog"&gt; &lt;div class="modal-dialog"&gt; &lt;div class="modal-content"&gt; &lt;form id="FormIns" action="Index.php" method="post"&gt; &lt;div class="modal-header"&gt; &lt;h4 class="text-center"&gt;Inscription&lt;/h4&gt; &lt;/div&gt; &lt;div class="modal-body"&gt; &lt;div class="row"&gt; &lt;div class="col-md-offset-3 col-md-6"&gt; &lt;input type="text" class="form-control" name="lastname" id="lname" placeholder="Nom" maxlength="25"&gt; &lt;/div&gt; &lt;/div&gt;&lt;br/&gt; &lt;div class="row"&gt; &lt;div class="col-md-offset-3 col-md-6"&gt; &lt;input type="text" class="form-control" name="firstname" id="fname" placeholder="Prénom" maxlength="25"&gt; &lt;/div&gt; &lt;/div&gt;&lt;br/&gt; &lt;div class="row"&gt; &lt;div class="col-md-offset-3 col-md-6"&gt; &lt;input type="text" class="form-control" name="nid" id="nidentifiant" placeholder="Identifiant" maxlength="25"&gt; &lt;/div&gt; &lt;/div&gt;&lt;br/&gt; &lt;div class="row"&gt; &lt;div class="col-md-offset-3 col-md-6"&gt; &lt;input type="password" class="form-control" name="npass" id="npassword" placeholder="Mot de Passe" maxlength="25"&gt; &lt;/div&gt; &lt;/div&gt;&lt;br/&gt; &lt;div class="row"&gt; &lt;div class="col-md-offset-3 col-md-6"&gt; &lt;input type="password" class="form-control" name="cnpass" id="cnpassword" placeholder="Confirmer Mot de Passe" maxlength="25"&gt; &lt;/div&gt; &lt;/div&gt;&lt;br/&gt; &lt;div class="row"&gt; &lt;div class="col-md-offset-3 col-md-6"&gt; &lt;input type="mail" class="form-control" name="mail" id="mail" placeholder="Adresse Email" maxlength="25"&gt; &lt;/div&gt; &lt;/div&gt;&lt;br/&gt; &lt;div class="row"&gt; &lt;div class="col-md-offset-3 col-md-6"&gt; &lt;input type="text" class="form-control" name="phone" id="phone" placeholder="Numéro de Téléphone" maxlength="25"&gt; &lt;/div&gt; &lt;/div&gt;&lt;br/&gt; &lt;div class="modal-footer"&gt; &lt;input class="btn btn-primary" type="submit" value="Inscription" name="log"&gt; &lt;a class="btn btn-default" data-dismiss="modal"&gt;Annuler&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> </div>

datetimepicker 影响Bootstrap 模态框的关闭

<div class="col-md-8"> <input class="form-control" placeholder="限办时间" id="limiteTimeStr" name="limiteTimeStr" value="<fmt:formatDate value='${tOrder.limiteTime}' pattern='yyyy-MM-dd'></fmt:formatDate>"> </div> $("[name='limiteTimeStr']").datetimepicker({ format:'yyyy-mm-dd', language: 'cn', todayBtn: true, clearBtn: true, autoclose: true, minView: 2, maxView: 4 }); url:WEBPATH+'/gdgl/saveOrder', type: 'post', success:function(data){ if(data.meta.result=='success'){ swal({title: "保存成功",text: "",type:"success"}); $("#myModal").modal('hide'); }else if(data.meta.code == '007'){ swal({ title : data.meta.message, text : "", type : "info" }); }else{ swal("保存失败!",data.data, "error"); } } 注销$("[name='limiteTimeStr']").datetimepicker({ format:'yyyy-mm-dd', language: 'cn', todayBtn: true, clearBtn: true, autoclose: true, minView: 2, maxView: 4 });这段保存成功或modal框正常关闭,不注销关闭不了

PHP HTML Bootstrap - 在Bootstrap形式中使用带有PHP的验证器插件

<div class="post-text" itemprop="text"> <p>I have a form that allows new users to be added to a database, but must this form must be 'authorised' with a valid code before being submitted. I have some PHP that works for this but the output is a crude tick or cross, indicating whether the code is valid or not. I want to instead make use of the <a href="http://1000hz.github.io/bootstrap-validator/" rel="nofollow noreferrer">Bootstrap Validator plugin</a> to indicate whether the code is valid or not, however I'm not sure how to go about this. I am using the validator plugin on the form already, but it is currently only testing whether or not the field has been filled in, rather than using the PHP to test whether or not the code in the field is valid. If anyone could have a look it would be greatly appreciated.</p> <p>Form.html:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; &lt;title&gt;Add New&lt;/title&gt; &lt;!-- Scripts --&gt; &lt;script src="js/jquery-3.1.1.min.js"&gt;&lt;/script&gt; &lt;script src="js/bootstrap.min.js"&gt;&lt;/script&gt; &lt;script src="js/validator.js"&gt;&lt;/script&gt; &lt;script src="js/validator.min.js"&gt;&lt;/script&gt; &lt;!-- CSS --&gt; &lt;link href="css/font-awesome.min.css" rel="stylesheet" type="text/css"&gt; &lt;link href="css/bootstrap.css" rel="stylesheet"&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="section text-left"&gt; &lt;div class="container"&gt; &lt;div class="row"&gt; &lt;div class="container-fluid"&gt; &lt;div class="row"&gt; &lt;div class="col-md-2"&gt;&lt;/div&gt; &lt;div class="col-md-8 col-sm-6 col-xs-12"&gt; &lt;!-- Padding --&gt; &lt;div class="col-xs-12" style="height:30px;"&gt; &lt;/div&gt; &lt;!-- Form begins --&gt; &lt;form action="insert_preflight.php" method="post" data-toggle="validator" data-disable="false"&gt; &lt;div class="form-group"&gt; &lt;label class="control-label " for="first_name"&gt;First Name&lt;/label&gt; &lt;input class="form-control" id="first_name" maxlength="40" name="first_name" type="text" required&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label class="control-label " for="last_name"&gt;Last Name&lt;/label&gt; &lt;input class="form-control" id="last_name" maxlength="40" name="last_name" type="text" required&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label class="control-label " for="dob"&gt;Date of Birth&lt;/label&gt; &lt;input class="form-control" id="dob" name="dob" maxlength="10" type="date"&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label class="control-label " for="email"&gt;Email&lt;/label&gt; &lt;input class="form-control" type="email" id="email" name="email" type="email"&gt; &lt;/div&gt; &lt;hr&gt; &lt;div class="form-group has-feedback" id="auth_code_form"&gt; &lt;label for="auth_code" class="control-label "&gt;Authorisation Code&lt;/label&gt; &lt;input class="form-control" id="auth_code" name="auth_code" type="password" required&gt; &lt;!-- &lt;span id="auth_code_result"&gt;&lt;/span&gt; --&gt; &lt;span id="auth_code_result" class="glyphicon form-control-feedback"&gt;&lt;/span&gt; &lt;/div&gt; &lt;hr&gt; &lt;div class="form-group"&gt; &lt;div&gt; &lt;button class="btn btn-info " name="submit" type="submit"&gt;Add&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { var x_timer; $("#auth_code").keyup(function(e) { clearTimeout(x_timer); var auth_code = $(this).val(); x_timer = setTimeout(function() { check_auth_code_ajax(auth_code); }, 1000); }); function check_auth_code_ajax(auth_code) { $("#auth_code_result").html('&lt;img src="ajax-loader.gif" /&gt;'); $.post('check.php', { 'auth_code': auth_code }, function(data) { $("#auth_code_result").html(data); }); } }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Check.php:</p> <pre><code>&lt;?php // Connection include 'pdo_config.php'; try { $conn = new PDO($dsn, $user, $pass, $opt); $auth_code = $_POST["auth_code"]; $stmt = $conn-&gt;prepare("SELECT * FROM tbl_instructors WHERE auth_code = :auth_code"); $stmt-&gt;bindParam(':auth_code', $auth_code); $stmt-&gt;execute(); $exists = $stmt-&gt;fetchColumn(); if(($exists &gt; 0)){ die('&lt;img src="exists.png" /&gt;'); }else{ die('&lt;img src="no_exists.png" /&gt;'); } } catch(PDOException $e) { echo "Error: " . $e-&gt;getMessage(); } $conn = null; </code></pre> </div>

通过Php验证后,Bootstrap Modal弹出窗口

<div class="post-text" itemprop="text"> <p>I want to pop up the Bootstrap modal in case of some validation error occur and display it on the modal. Php validation occur after page reload so in case of error occur, bootstrap modal should pop up with respective errors.</p> <p>This the code for modal.</p> <p></p> <pre><code> &lt;div class="modal-dialog"&gt; &lt;!-- Modal content--&gt; &lt;div class="modal-content" &gt; &lt;div class="modal-header" style="padding:35px 50px;"&gt; &lt;button type="button" class="close" data-dismiss="modal"&gt;&amp;times;&lt;/button&gt; &lt;h3&gt;&lt;span class="glyphicon glyphicon-lock"&gt;&lt;/span&gt; Login&lt;/h3&gt; &lt;/div&gt; &lt;div class="modal-body" style="padding:40px 50px;"&gt; &lt;form role="form" method="post" action="&lt;?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?&gt;"&gt; &lt;div class="form-group"&gt; &lt;label for="usrname"&gt;&lt;span class="glyphicon glyphicon-user"&gt;&lt;/span&gt; Username&lt;/label&gt; &lt;input type="text" class="form-control" id="u_email" name="u_email" value="&lt;?php echo $u_email;?&gt;" placeholder="Enter email"&gt; &lt;span class="error"&gt; &lt;?php echo $u_emailErr;?&gt;&lt;/span&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label for="psw"&gt;&lt;span class="glyphicon glyphicon-eye-open"&gt;&lt;/span&gt; Password&lt;/label&gt; &lt;input type="text" class="form-control" id="password" name="password" value="&lt;?php echo $password;?&gt;" placeholder="Enter password"&gt; &lt;span class="error"&gt; &lt;?php echo $passwordErr; echo $count;?&gt;&lt;/span&gt; &lt;/div&gt; &lt;div class="checkbox"&gt; &lt;label&gt;&lt;input type="checkbox" value="" checked&gt;Remember me&lt;/label&gt; &lt;/div&gt; &lt;button type="submit" class="btn btn-success"&gt;&lt;span class="glyphicon glyphicon-off"&gt;&lt;/span&gt; Login&lt;/button&gt; &lt;/form&gt; &lt;/div&gt; &lt;div class="modal-footer"&gt; &lt;button type="submit" class="btn btn-danger btn-default pull-left" data-dismiss="modal"&gt;&lt;span class="glyphicon glyphicon-remove"&gt;&lt;/span&gt; Cancel&lt;/button&gt; &lt;p&gt;Not a member? &lt;a href="#" data-dismiss="modal" data-toggle="modal" data-target="#myModal1" data-backdrop="static" &gt;Sign Up&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Forgot &lt;a href="#"&gt;Password?&lt;/a&gt;&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p><strong>Php</strong> This is php validation.</p> <pre><code>&lt;?php // define variables and set to empty values $u_emailErr = $passwordErr = ""; $u_email = $password = ""; $count = 0; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["u_email"])) { $u_emailErr = "Email is required"; $count++; } else { $u_emailErr = test_input($_POST["u_email"]); // check if e-mail address is well-formed if (!filter_var($u_email, FILTER_VALIDATE_EMAIL)) { $u_emailErr = "Invalid email format"; $count++; } } if (empty($_POST["password"])) { $passwordErr = "Password is required"; $count++; } else { $passwordErr = test_input($_POST["u_email"]); } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?&gt; </code></pre> <p>Anyone can help...........?</p> </div>

Bootstrap模式中的WordPress自定义联系表单未显示验证和提交响应

<div class="post-text" itemprop="text"> <p>For my WordPress I am using Bootstrap and built a Custom Contact form with below HTML (followed this tutorial: <a href="https://premium.wpmudev.org/blog/how-to-build-your-own-wordpress-contact-form-and-why/" rel="nofollow noreferrer">https://premium.wpmudev.org/blog/how-to-build-your-own-wordpress-contact-form-and-why/</a>).</p> <pre><code>&lt;form id="contact-form" action="&lt;?php echo get_site_url(); ?&gt;" method="post"&gt; &lt;div class="modal-body"&gt; &lt;?php echo $response; ?&gt; &lt;div class="form-group"&gt; &lt;input class="form-control my-2" type="text" name="message_name" size="50" placeholder="Your full name" value="&lt;?php echo esc_attr($_POST['message_name']); ?&gt;"&gt; &lt;input class="form-control my-2" type="email" name="message_email" size="50" placeholder="Email address" value="&lt;?php echo esc_attr($_POST['message_email']); ?&gt;"&gt; &lt;input class="form-control my-2" type="tel" name="message_tel" size="50" placeholder="Country code, Phone number" value="&lt;?php echo esc_attr($_POST['message_tel']); ?&gt;"&gt; &lt;textarea class="form-control my-2" name="message_text" rows="2" placeholder="Your message" value="&lt;?php echo esc_attr($_POST['message_text']); ?&gt;"&gt;&lt;/textarea&gt; &lt;input class="form-control my-2" type="text" name="message_human" placeholder="Human check: Enter 2"&gt; &lt;input type="hidden" name="message_url" value="&lt;?php the_permalink(); ?&gt;"&gt; &lt;input type="hidden" name="message_page" value="&lt;?php the_title(); ?&gt;"&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="modal-footer"&gt; &lt;input type="hidden" name="submitted" value="1"&gt; &lt;button type="submit" value="Submit" class="btn btn-search form-control"&gt;Send Enquiry&lt;/button&gt; &lt;/div&gt; </code></pre> <p></p> <p>Below the function to validate the Forms &amp; show responses while Form submission:</p> <pre><code>//response generation function $response = ""; //function to generate response function contact_g_form_response($type, $message) { global $response; if ($type == "success") { $response = "&lt;div class='message-success text-center'&gt;{$message}&lt;/div&gt;"; } else { $response = "&lt;div class='message-error text-center'&gt;{$message}&lt;/div&gt;"; } } //response messages $not_human = "Enter current year in numbers."; $missing_content = "Missing something."; $email_invalid = "Check your Email address."; $message_unsent = "Message was not sent. Try Again."; $message_sent = "Thanks! We got your enquiry."; //user posted variables $name = $_POST['message_name']; $email = $_POST['message_email']; $fromEmail = $name . '&lt;' . $email . '&gt;'; $tel = $_POST['message_tel']; $text = $_POST['message_text']; $url = $_POST['message_url']; $page = $_POST['message_page']; $human = $_POST['message_human']; //php mailer variables $to = get_option('admin_email'); $subject = '[General Enquiry] ' . $name . ' | Phone Number:' . $tel; $headers = 'From: ' . $fromEmail . " " . 'Reply-To: ' . $email . " "; $message = '&lt;html&gt;&lt;body&gt;&lt;h1&gt;New general enquiry from ' . $name . '!&lt;/h1&gt;' . '&lt;p&gt;Email: ' . $email . '&lt;/p&gt;' . '&lt;p&gt;Phone Number: ' . $tel . '&lt;/P&gt;' . '&lt;p&gt;Inquiry: ' . $text . '&lt;/P&gt;' . '&lt;p&gt;From page: &lt;b&gt;' . $page . '&lt;/b&gt;&lt;/P&gt;' . '&lt;p&gt;Page URL: ' . $url . '&lt;/p&gt;' . '&lt;/body&gt;&lt;/html&gt;'; if (!$human == 0) { if ($human != 2) { contact_g_form_response("error", $not_human); //not human! } else { //validate email if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { contact_g_form_response("error", $email_invalid); } else { //email is valid //validate presence of name, phone number if (empty($name) || empty($tel)) { contact_g_form_response("error", $missing_content); } else { //ready to go! $sent = wp_mail($to, $subject, $message, implode(" ", $headers)); //mail to admin - striptags removing formatting // $sent2 = wp_mail($email, $subject, $body, $headers); //mail to visitor // if ($sent || $sent2) { if ($sent) { contact_g_form_response("success", $message_sent); //message sent! } else { contact_g_form_response("error", $message_unsent); //message wasn't sent } } } } } else if ($_POST['submitted']) { contact_g_form_response("error", $missing_content); } </code></pre> <p>Although the Form is being successfully submitted, no response / validation messages are shown as per <code>contact_g_form_response</code>function and after the Form submission, it is being redirected to a random WordPress post.</p> </div>

easyui textbox 设置属性editable: false, required: true 表单验证的时候会不弹出提示信息

<input id="CustID" name="CustID" class="easyui-textbox" /> $("#CustID").textbox({ missingMessage: '此项必输', prompt: '请单击右侧\'放大镜\'按钮进行操作!', editable: false, tipPosition: 'bottom', required: true, multiline: false, width: '350px', buttonText: '', buttonIcon: 'icon-search', onClickButton: function () { GetSysPointId(); }, icons: [{ iconCls: 'icon-clear', handler: function (e) { $(e.data.target).textbox('clear'); } }] });

关于Firefox问题的PHP表单(此地址未被理解)

<div class="post-text" itemprop="text"> <p>-HTML code-</p> <pre><code>&lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"&gt;&lt;/script&gt; &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="container text-justify"&gt; &lt;h1&gt;Fill this form pliz&lt;/h1&gt; &lt;div class="form-group"&gt; &lt;form name="myform" method="post" action="formdb.php"&gt; First name:&lt;br&gt; &lt;input type="text" name="fname" placeholder=" First-name" required&gt; &lt;br&gt; Second name:&lt;br&gt;&lt;input type="text" name="fname" placeholder=" Second-name" required&gt; &lt;br&gt; Age:&lt;br&gt;&lt;input type="number" name="age" min="15" max="100" placeholder=" Age"&gt; &lt;br&gt; Email:&lt;br&gt;&lt;input type="email" name="email" placeholder=" E-mail"&gt; &lt;br&gt;&lt;br&gt; Gender:&lt;br&gt; &lt;input type="radio" name="gender" value="Male"&gt; Male&lt;br&gt; &lt;input type="radio" name="gender" value="Female"&gt; Female &lt;br&gt; &lt;input type="radio" name="gender" value="Other"&gt; Other &lt;br&gt; Password:&lt;br&gt;&lt;input type="password" name="password" placeholder=" Password"&gt; &lt;br&gt;&lt;br&gt; &lt;input type="submit"&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>-PHP code-</p> <pre><code>&lt;?php echo "Values recieved"."&lt;br&gt;"; $fname=$lname=$age=$email=$sex=$pass=""; function test_input($data){ $data=trim($data); $data=stripslashes($data); $data=htmlspecialchars($data); return $data; } if($_SERVER["REQUEST_METHOD"]=="POST") { echo"bitch"; $fname=test_input($_POST['fname']); $lname=test_input($_POST['lname']); $age=test_input($_POST['age']); $sex=test_input($_POST['gender']); $email=test_input($_POST['email']); $pass=test_input($_POST['password']); } echo "First name is ".$fname; ?&gt; </code></pre> <p>When I submit the form, I get an error from Firefox saying that "This address wasn't understood". Both the PHP and HTML are located in the same directory. Is it an issue caused by Firefox or is there an error on my part?</p> </div>

与codeigniter的表单验证问题

<div class="post-text" itemprop="text"> <p>I'm trying to develop a simple login system, but i'm facing issue during data validation.</p> <p>Everything works if I enter valid data.</p> <p>but when i enter invalid data it like empty user or password, it gives me validation erorr, but after that if i enter the correct user data. it wont work, it will just reload the the same page. The strange thing that i noticed is that the url on the address bar keeps getting longer.</p> <p>My login url after clicking submit button the first time.</p> <p><a href="http://localhost/ci/login/validate" rel="nofollow">http://localhost/ci/login/validate</a></p> <p>My login url after clicking submit button the second time.</p> <p><a href="http://localhost/ci/login/login/validate" rel="nofollow">http://localhost/ci/login/login/validate</a></p> <p>Every time i click the submit button, it keeps adding an extra '/login' to url.</p> <p>any idea what the problem is?</p> <p>My <strong>main</strong> controller</p> <pre><code> &lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Login extends CI_Controller { public function index() { $this-&gt;load-&gt;view('login/header'); $this-&gt;load-&gt;view('login/login_view'); $this-&gt;load-&gt;view('login/footer'); } public function validate() { $this-&gt;load-&gt;model('login_model'); $this-&gt;load-&gt;library('form_validation'); $this-&gt;form_validation-&gt;set_rules('username','Username', 'trim|required|min_length[6]|max_length[50]|valid_email|xss_clean'); $this-&gt;form_validation-&gt;set_rules('password','Password', 'trim|required|xss_clean'); //validation check if ($this-&gt;form_validation-&gt;run() == FALSE) { $this-&gt;load-&gt;view('login/header'); $this-&gt;load-&gt;view('login/login_view'); $this-&gt;load-&gt;view('login/footer'); } else { $userdata['username'] = $_POST['username']; $userdata['password'] = md5($_POST['password']); //check whether user exist int the database or not $result = $this-&gt;login_model-&gt;login_validation($userdata); //in case user exists if($result == 1) { $this-&gt;set_sessions_details(); } //in case user doesnt exist else { $data['flag'] = "Incorrect Username or Password!"; $this-&gt;load-&gt;view('login/header'); $this-&gt;load-&gt;view('login/login_view', $data); $this-&gt;load-&gt;view('login/footer'); } } } //load a view in case user exists in the db. public function set_sessions_details() { $this-&gt;load-&gt;view('test'); } } </code></pre> <p>My model to check user data in db.</p> <p><strong>login_model</strong> </p><pre><code> class Login_model extends CI_Model { function login_validation($userdata) { $user=$userdata['username']; $pass=$userdata['password']; $result = $this-&gt;db-&gt;get_where('users', array('username' =&gt; $user, 'password' =&gt; $pass)); return $result-&gt;num_rows(); } } ?&gt; </code></pre> <p>My views:</p> <p><strong>login_view</strong></p> <pre><code>&lt;h3&gt;Please Login&lt;/h3&gt; &lt;form method='post' action='login/validate'&gt; &lt;div class="form-group" &gt; &lt;label for="username"&gt;Username&lt;/label&gt; &lt;input type="email" class="form-control" name="username" id="username" placeholder="Enter Username"&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label for="password"&gt;Password&lt;/label&gt; &lt;input type="password" class="form-control" name="password" id="password" placeholder="Enter Password"&gt; &lt;/div&gt; &lt;button type="submit" class="btn btn-success"&gt;Login&lt;/button&gt; &lt;?php echo validation_errors('&lt;p class"errors"&gt;');?&gt; &lt;/form&gt; &lt;?php if (isset($flag)){ ?&gt; &lt;p&gt;&lt;?php echo $flag; ?&gt; &lt;/p&gt; &lt;?php } ?&gt; </code></pre> <p><strong>header</strong></p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; &lt;title&gt;WFD&lt;/title&gt; &lt;link href="&lt;?php echo base_url();?&gt;assets/css/bootstrap.min.css" rel="stylesheet"&gt; &lt;!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --&gt; &lt;!-- WARNING: Respond.js doesn't work if you view the page via file:// --&gt; &lt;!--[if lt IE 9]&gt; &lt;script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"&gt;&lt;/script&gt; &lt;script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"&gt;&lt;/script&gt; &lt;![endif]--&gt; &lt;/head&gt; &lt;body&gt; &lt;div class='container'&gt; &lt;div class="header"&gt; &lt;center&gt;&lt;img src="&lt;?php echo base_url();?&gt;assets/images/logo.png" alt="logo" style="margin-top: 10px; padding-bottom: 20px; opacity: 1;"&gt; &lt;h2&gt; Welfare Foundation Database &lt;/h2&gt; &lt;/center&gt; &lt;/div&gt; </code></pre> <p><strong>Footer</strong></p> <pre><code> &lt;/div&gt; &lt;!-- jQuery (necessary for Bootstrap's JavaScript plugins) --&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt; &lt;!-- Include all compiled plugins (below), or include individual files as needed --&gt; &lt;script src="/ci/assets/js/bootstrap.min.js"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> </div>

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

外包程序员的幸福生活

今天给你们讲述一个外包程序员的幸福生活。男主是Z哥,不是在外包公司上班的那种,是一名自由职业者,接外包项目自己干。接下来讲的都是真人真事。 先给大家介绍一下男主,Z哥,老程序员,是我十多年前的老同事,技术大牛,当过CTO,也创过业。因为我俩都爱好喝酒、踢球,再加上住的距离不算远,所以一直也断断续续的联系着,我对Z哥的状况也有大概了解。 Z哥几年前创业失败,后来他开始干起了外包,利用自己的技术能...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

深入剖析Springboot启动原理的底层源码,再也不怕面试官问了!

大家现在应该都对Springboot很熟悉,但是你对他的启动原理了解吗?

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

你期望月薪4万,出门右拐,不送,这几个点,你也就是个初级的水平

先来看几个问题通过注解的方式注入依赖对象,介绍一下你知道的几种方式@Autowired和@Resource有何区别说一下@Autowired查找候选者的...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《Oracle Java SE编程自学与面试指南》最佳学习路线图2020年最新版(进大厂必备)

正确选择比瞎努力更重要!

《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)

正确选择比瞎努力更重要!

字节跳动面试官竟然问了我JDBC?

轻松等回家通知

面试官:你连SSO都不懂,就别来面试了

大厂竟然要考我SSO,卧槽。

终于,月薪过5万了!

来看几个问题想不想月薪超过5万?想不想进入公司架构组?想不想成为项目组的负责人?想不想成为spring的高手,超越99%的对手?那么本文内容是你必须要掌握的。本文主要详解bean的生命...

自从喜欢上了B站这12个UP主,我越来越觉得自己是个废柴了!

不怕告诉你,我自从喜欢上了这12个UP主,哔哩哔哩成为了我手机上最耗电的软件,几乎每天都会看,可是吧,看的越多,我就越觉得自己是个废柴,唉,老天不公啊,不信你看看…… 间接性踌躇满志,持续性混吃等死,都是因为你们……但是,自己的学习力在慢慢变强,这是不容忽视的,推荐给你们! 都说B站是个宝,可是有人不会挖啊,没事,今天咱挖好的送你一箩筐,首先啊,我在B站上最喜欢看这个家伙的视频了,为啥 ,咱撇...

立即提问
相关内容推荐