I have 2 questions regarding Validation Behavior in DNN.
We have a simple Contact Form /sub form and are preventing it from executing a submit due to the rest API that it will be using? Questions are:
1. Is there a way to completely remove DNN's default form action "action='\'"? We are currently using "return false" in the javascript function.
2.How do you remove the "This is a required field" popup and change the red border thickness? Tried many recommendations on this, but none work including:
$("Form").validate({
errorPlacement: function () {
return true;
}
and modifying the css:
.error {
color: red;
border: 1px solid red;
}
3. Using $('#Form').validate().valid() always returns true and causes fields on the form to disappear, validations not to work, and strange behavior. How does one work around this. The code is below
function SendMessage() {
if ($('#Form').validate().valid()) {
//"message passed");
var params = {
eMail: {
Name: $('#<%=Name.ClientID%>').val(), ...............
}
//Rest API Inteface here .......
}
}
else {
// message not ready;
}
<div style="max-width: 400px" id="ContactForm">
<div>
<p>
<asp:TextBox runat="server" ID="Name" Name="Name"
placeholder="First and Last Name" minlength="6" type="text"
required="true"
class="form-control"
onBlur="this.value=CapFirstLetters(CleanData(this.value));" />
</p>
</div>
<div>
<p>
<asp:TextBox runat="server" Name="Phone" ID="Phone" placeholder="Phone" type="usphonenumber" required="true" class="form-control" />
</p>
</div>
<div>
<p>
<asp:TextBox runat="server" ID="Email" placeholder="email Address" type="email" required="true" class="form-control" />
</p>
</div>
<div>
<p>
<asp:TextBox runat="server" ID="Message" placeholder="Message . . .100 Character Minimum"
class="form-control" Height="150px" TextMode="MultiLine"
spellcheck="true"
required="true"
minlength="65" onBlur="this.value=CleanData(this.value);"
title="email Message"
data-toggle="popover"
data-trigger="focus"
data-placement="right"
data-content="Please include a complete description of your question. A minimum of 100 characters is required." />
</p>
</div>
<div style="text-align: right;">
<button type="submit" class="btn btn-primary" onclick="return SendMessage()">Send</button>
</div>
</div>