It is crucial to adhere to the code convention in computer programming. The indentation style serves as a guideline for organizing blocks of code and conveying program structure. Unlike some languages that use braces or keywords, languages like Python and occam rely on indentation to determine structure, known as the off-side rule.
If you introduce multi-space errors, it can lead to issues with attribute values such as your class
value appearing as
samplebtn e-control e-btn e-primary"
type="submit" style="height:40px;width: 150px;" data-ripple="true">
.
This misconception can cause the error to think that Submit
is another attribute of your button
, resulting in confusion about how to handle the following <
.
To prevent such errors, it is important to follow the convention outlined below for optimal functionality.
Same line convention
function myFunction() {
alert('your form is submitted');
}
<button id="validateSubmit" [disabled]="reactForm.invalid" onclick="myFunction()" class="samplebtn e-control e-btn e-primary" type="submit" style="height:40px; width: 150px;" data-ripple="true">Submit</button>
Indentation convention
Alternatively, you can indent each attribute for better readability.
function myFunction() {
alert('your form is submitted');
}
<button
id="validateSubmit"
[disabled]="reactForm.invalid"
onclick="myFunction()"
class="samplebtn e-control e-btn e-primary"
type="submit"
style="height:40px;width: 150px;"
data-ripple="true">Submit</button>