crescue
asked on
bootstrap and php contact form
I am trying to display a message in my bootstrap page IF THERE IS AN ERROR IN THE EMAIL FIELDS
I am using :
<div class="form-group">
<div class="col-sm-10 col-sm-offset-2">
<! Will be used to display an alert to the user>
</div>
</div>
I am able to execute the email.php form correctly if everything is fine, but if there is an error I am using
header("location:javascrip t://histor y.go(-1)") ;
to go to the previous page with the USER INPUT. I have tried several examples from the web and tutorials, but NONE of them have worked for me but this one (history)
My problem is that since it is history page, NO MESSAGE IS DISPLAYED
My question is HOW CAN I APPEND INFO TO MY FIELDS IN BOOTSTRAP LIKE THE ALERT PREVIOUSLY POSTED
Tnx
contactus.htm
I am using :
<div class="form-group">
<div class="col-sm-10 col-sm-offset-2">
<! Will be used to display an alert to the user>
</div>
</div>
I am able to execute the email.php form correctly if everything is fine, but if there is an error I am using
header("location:javascrip
to go to the previous page with the USER INPUT. I have tried several examples from the web and tutorials, but NONE of them have worked for me but this one (history)
My problem is that since it is history page, NO MESSAGE IS DISPLAYED
My question is HOW CAN I APPEND INFO TO MY FIELDS IN BOOTSTRAP LIKE THE ALERT PREVIOUSLY POSTED
Tnx
contactus.htm
header("location:javascripThis is not a good idea.t://histor y.go(-1)") ;
You have two options with validation
1. You submit the form to your server script - it validates the form and if errors renders the page out again with the fields filled out with the user inputs and any error messages - this was the old way and quite cumbersom
2. You submit your form data via an AJAX call to a server side service. The service validates the data and sends back a list of errors. As you have not left the page all the user inputs are still there - all that is required is to add the errors to their respective form elements.
If the page submit is successful you simply redirect (window.location = ....) to the next page.
Option 2 is much easier to implement and is the current trend in dealing with form data.
ASKER
Leonidas, tnx for your help but the email was already validated by INPUT TYPE 'Email'. if I clicked the 'Submit' and the email was incorrect, a message from bootsrtap would appear, I wanted to Validate Name (none blank) and the HUMAN answer Correct BEFORE submitting the form
Yes, I like your red message, could it be centered too :-)
But mostly I would like to validate those 3 fields before submitting the form
Tnx
Yes, I like your red message, could it be centered too :-)
But mostly I would like to validate those 3 fields before submitting the form
Tnx
ASKER
Hi, I was able to fix validation with 'Required', and how do I validate the Human answer to be 5 in order to send
Tnx for your help and the right track
Tnx for your help and the right track
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Tnx for the right path
You are welcome.
I made a validation RegEx code.When the email is not right then e message appears in a red background color:
Open in new window